@messages = current_user.message_parti开发者_C百科cipantions.where(:read => false, :updated_at > 5.days.ago)
The updated_at 5 days ago errors. Do I need to use a format like so:
find(:all, :conditions => ["created_at > ?", 5.days.ago])
You could do:
@messages = current_user.message_participantions.where("read = ? AND updated_at > ?", false, 5.days.ago)
Or if for some reason you need to use the hash:
@messages = current_user.message_participantions.where(:read => false, :updated_at => 5.days.ago..Time.now)
As the values of the hash argument to the where method can be exact values or ranges: http://api.rubyonrails.org/classes/ActiveRecord/Base.html
@messages = current_user.message_participantions.where(:read => false).where("updated_at > ?", 5.days.ago)
I would:
@messages = current_user.message_participantions.where(["read = 0 AND updated_at > ?", 5.days.ago])
精彩评论