i am working on a task management system for the company i work for. i
just got the rails cookbook and am trying to use the section on creating
a drag and drop sortable list.
the tricky part is that my Task model references the User model in two
different spots. i have one field for the creator of the task and
another for the assignee. so in my Task model i have the following code:
class Task < ActiveRecord::Base
belongs_to :assignee,
:class_name => ‘User’,
:foreign_key => ‘assignee_id’
belongs_to :creator,
:class_name => ‘User’,
:foreign_key => ‘creator_id’
has_many :comments, :dependent => destroy
validates_presence_of :title, :description, :date_due
acts_as_list :scope => :assignee
end
and this is what i have in my User model:
class User < ActiveRecord::Base
has_many :assigned,
:class_name => ‘Task’,
:foreign_key => ‘assignee_id’
has_many :created,
:class_name => ‘Task’,
:foreign_key => ‘creator_id’
has_many :comments, :dependent => destroy
validates_uniqueness_of :username
validates_presence_of :username, :password, :full_name, :email
end
everything works like it’s supposed to until i added the acts_as_list at
the bottom of the Task model. for the scope, i’m not sure what i should
put. when i create a new task, the position is always nil. i’m not sure
if i can use it the way i am trying to or if there is something else i
have to put when my database field names are different than the expected
conventions.
if anyone has any input, i would greatly appreciate it.
thanks