Rails 3, adding joins to default_scope for association of current_user
In my app i have a schema of Users and Tickets, each User can be
subscribed to many Tickets and viceversa.
For each ticket i fetch from the database, i want to display if
current_user is subscribed or not to the ticket itself.
An example of my query is as follows:
@tickets = current_user.tickets.limit(10).order('created_at DESC')
Can i do it using a default_scope with a join in Ticket model?, i need it
to return an additional field with a simple true or false, or nil.
Thank you.
No comments:
Post a Comment