http://ihower.tw/rails3/activerecord-relationships.html
many-to-many,按照他写的教程,rails console 出现错误
g = Group.create( :name => 'ruby taiwan' ) e1 = Event.first e2 = Event.create( :name => 'ruby tuesday' ) EventGroupship.create( :event => e1, :group => g ) # => ActiveModel::MassAssignmentSecurity::Error: Can't mass-assign protected attributes: event, group EventGroupship.create( :event => e2, :group => g )
如果,改成 EventGroupship.create( :event_id => e1.id, :group_id => g.id ), 则, g.events #=>[ ] 剩下的也都是空集。
g.events e1.groups e2.groups
这个问题怎么解决?
谢谢