开发者

Is it possible to implement has_many, :through with ActiveScaffold?

开发者 https://www.devze.com 2022-12-26 23:28 出处:网络
Consider the following models: class Artist < ActiveRecord::Base has_many :artist_events has_many :events, :through => :artist_events

Consider the following models:

class Artist < ActiveRecord::Base
  has_many :artist_events
  has_many :events, :through => :artist_events
end

class Event < ActiveRecord::Base
  has_many :artist_events
  has_many :artists, :through => :artist_events, :order => 'artist_events.position'
end

class ArtistEvent < ActiveRecord::Base
  default_scope :order => 'position'
  belongs_to :artist
  belongs_to :event
  acts_as_list :scope => :artist
end

Is is possible to us开发者_高级运维e ActiveScaffold to administer this type of relationship? The ArtistEvent model exists to define a hbtm relationship with additional attribute of position.

Thanks!

Jonathan


yes. after all, ArtistEvent is yet another model - and active scaffold can operate on it as long as you have routes and controllers on the join model.

0

精彩评论

暂无评论...
验证码 换一张
取 消