Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

acts_as_list with has_and_belongs_to_many relationship

I've found an old plugin called acts_as_habtm_list - but it's for Rails 1.0.0.

Is this functionality built in acts_as_list now? I can't seem to find any information on it.

Basically, I have an artists_events table - no model. The relationship is handled through those two models specifying :has_and_belongs_to_many

How can I specify order in this situation?

like image 427
mculp Avatar asked Feb 16 '10 17:02

mculp


1 Answers

Additional update for the accepted answer: for Rails 4 and Rails 5:

has_many :events, -> { order 'artist_events.position ASC' }, through: :artist_events
has_many :artists, -> { order 'artist_events.position ASC' }, through: :artist_events
like image 50
Roel4811 Avatar answered Nov 15 '22 18:11

Roel4811