Reputation: 10208
I have three models: User, Task and Assignation. User has many tasks through assignation. Tasks has many users through assignation.
class User < ActiveRecord::Base
has_many :assignations
has_many :tasks, :through => :assignations
...
class Task < ActiveRecord::Base
has_many :assignations
has_many :users, :through => :assignations
I have a partial which shows all the tasks of the selected user. How can I make the condition efficiently so I can get the collection of tasks?
i.e.
user_id = params[:user_id]
@tasks = Task.find(:all, :conditions=> .....)
Regards.
Upvotes: 0
Views: 1181