My User
model has_many
messages
I would like to retrieve the model's unread messages as a relation so I can chain it
at the moment, the only thing that worked for me is
class Message
scope :unread, lambda{ |user| where("receiver_open = false AND received_messageable_id = ?", user.id)}
and then access it as
current_user.messages.unread(current_user)
you can see that this is a bit smelly
Is there way to make the scope use the current_user which I used to invoke the scope? so that it would be current_user.messages.unread