June 9th, 2010, 02:47 AM
Join Date: Apr 2005
Time spent in forums: 21 h 7 m 8 sec
Reputation Power: 9
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:
class User< ActiveRecord::Base
has_many :tasks, :class_name => "Task", :foreign_key=>"assigned_by"
has_many :todo, :class_name => "Task", :foreign_key =>"assigned_to"
class Task< ActiveRecord::Base
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.
@ PresentSoft Technologies Pvt. Ltd.
, a software development firm in Goa - India, we develop scalable applications using on Ruby on Rails and Android.
My blog @ AnayKamat.com