
June 9th, 2010, 01:47 AM
|
|
Contributing User
|
|
Join Date: Apr 2005
Posts: 107
 
Time spent in forums: 20 h 8 m 58 sec
Reputation Power: 9
|
|
Hi,
First, it would be good if you name your tables as users and tasks (as per the rails convention).
Now coming back to your problem, you could try the following code instead:
Code:
class User< ActiveRecord::Base
has_many :tasks, :class_name => "Task", :foreign_key=>"assigned_by"
has_many :todo, :class_name => "Task", :foreign_key =>"assigned_to"
end
class Task< ActiveRecord::Base
belongs_to :user
end
This way, you can then use user.tasks to see all the tasks assigned by him, and user.todo as the tasks which he needs to do.
I hope I have understood your problem correctly and the solution is what you need.
|