# How to use scope with acts\_as\_list

**URL:** <https://www.ruby-forum.com/t/how-to-use-scope-with-acts-as-list/96289>\
**Category:** Rails\
**Created:** [June 27, 2006, 11:10pm UTC](https://www.ruby-forum.com/t/how-to-use-scope-with-acts-as-list/96289 "2006-06-27T23:10:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jjkiesch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc79bd/32.png) [@jjkiesch](https://www.ruby-forum.com/u/jjkiesch)\
**Post date:** [June 27, 2006, 11:10pm UTC](https://www.ruby-forum.com/t/how-to-use-scope-with-acts-as-list/96289/1 "2006-06-27T23:10:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jjkiesch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc79bd/32.png) [@jjkiesch](https://www.ruby-forum.com/u/jjkiesch)\
**Post date:** [June 28, 2006, 5:38pm UTC](https://www.ruby-forum.com/t/how-to-use-scope-with-acts-as-list/96289/2 "2006-06-28T17:38:50Z")

</div>

If someone could just tell me what scopte refers to, maybe I can figure  
it out on my own. I’m not sure if I use the class, the mysql field, or  
the name I gave it in the model.

---

<div class="post-metadata">

**Author:** ![jjkiesch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc79bd/32.png) [@jjkiesch](https://www.ruby-forum.com/u/jjkiesch)\
**Post date:** [June 28, 2006, 5:39pm UTC](https://www.ruby-forum.com/t/how-to-use-scope-with-acts-as-list/96289/3 "2006-06-28T17:39:04Z")

</div>

If someone could just tell me what scope refers to, maybe I can figure  
it out on my own. I’m not sure if I use the class, the mysql field, or  
the name I gave it in the model.
