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.
Stephen B. (Guest)
on 2007-05-22 10: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
Thorsten (Guest)
on 2007-05-22 14: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 B. <removed_email_address@domain.invalid>
Stephen B. (Guest)
on 2007-05-22 17:03
(Received via mailing list)

Thanks for taking the time to write Thorsten. That makes everything MUCH
more clear!
jufemaiz: joel courtney (Guest)
on 2007-06-04 17: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 B. <removed_email_address@domain.invalid>
This topic is locked and can not be replied to.