Wednesday, 11 September 2013

Update records imminently after rails controller action?

Update records imminently after rails controller action?

My app has activity notifications, each has a flag 'seen' which I use to
check if the user has looked at them.
My controller looks like this:
def index
@unseen_activities = current_user.notifications.unseen.order(:updated_at
=> :desc)
@seen_activities = current_user.notifications.seen.order(:updated_at =>
:desc)
# mark them as viewed
current_user.notifications.update_all(:seen => true)
end
But the activities are all loaded as having been seen, even though this is
updated after the collections are made. What am I missing? #noob

No comments:

Post a Comment