Forum: Ruby on Rails can I use acts_as_list with a has_many :through association

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
6f608b6766f79343062a2aa3985933dc?d=identicon&s=25 Stephen Bannasch (Guest)
on 2007-05-22 08:38
(Received via mailing list)
I'd like to be able to use a has_many :through association and treat
the associations as a list but I'm getting this error when I try an
use an acts_as_list method:

   NoMethodError: undefined method `move_to_bottom'

I'm using edge rails r6786.

Here are my domain rules:

   Activities are things students can do.
   Units consists of a sequenced list of Activities.
   Activities can be used in many Units.

Here are the associations for these rules:

class Activity < ActiveRecord::Base
   has_many :unit_activities
   has_many :units, :through => :unit_activities

class Unit < ActiveRecord::Base
   has_many :unit_activities, :order => :position
   has_many :activities, :through => :unit_activities

class UnitActivity < ActiveRecord::Base
   belongs_to :activity
   belongs_to :unit
   acts_as_list :scope => :unit_id

In he example below in script/console I load in some previously
created activities; make a new unit; and add the activities to the

>>  activity_crystals = Activity.find_by_name("Molecular crystals")
>>  activity_browning = Activity.find_by_name("Brownian motion")
>>  activity_mixing = Activity.find_by_name("Temperature of mixing
>>water - TEEMSS demo")
>>  my_unit = Unit.create(:name => "My First Unit", :description => "A
>>simple test unit to see if thenew associations work")

>>  my_unit.activities.push(activity_crystals, activity_browning,

>>  my_unit.activities.each { |a| puts "#{}: #{}" }; nil
55: Molecular crystals
42: Brownian motion
25: Temperature of mixing water - TEEMSS demo

Here's where the error occurs:

>>  my_unit.activities[0].move_to_bottom
NoMethodError: undefined method `move_to_bottom' for

At this point my unit_activities table looks like this:

   id  activity_id  unit_id  position
   1     55            1       1
   2     42            1       2
   3     25            1       3
D7c511ce5025d37b8c6bd9134e0f2bd9?d=identicon&s=25 Thorsten (Guest)
on 2007-05-22 12:03
(Received via mailing list)
my_unit.activities accesses the items of the Activities table, which
are not marked as acts_as_list
The unit_activities items are enabled as acts_as_list.
Unit -> unit_activites -------> activties
           (acts_as_list)          (NOT acts_as_list)

by adding these activities to your association, a new unit_activities
item was created for each activity. and those are acts_as_list

try this:


On 22 Mai, 08:30, Stephen Bannasch <>
6f608b6766f79343062a2aa3985933dc?d=identicon&s=25 Stephen Bannasch (Guest)
on 2007-05-22 15:03
(Received via mailing list)

Thanks for taking the time to write Thorsten. That makes everything MUCH
more clear!
6fdd47232613d4baaffaf23c73e8969a?d=identicon&s=25 jufemaiz: joel courtney (Guest)
on 2007-06-04 15:06
(Received via mailing list)
Had problems with this too. Something you might want to have a look at
is this:

Finally got things working.

On May 22, 10:42 pm, Stephen Bannasch <>
This topic is locked and can not be replied to.