ruby on rails - has_many through form not registering in the join table -
ruby on rails - has_many through form not registering in the join table -
i have problem ruby on rails 4 app activeadmin gem have generated multiple resources works have problem resource has has_many through relationship. new records not registered through bring together table.
here model :
video.rb
class video < activerecord::base has_many :album_videos has_many :albums, :through => :album_videos end
album.rb
class album < activerecord::base has_many :album_videos has_many :videos, :through => :album_videos end
album_video.rb
class albumvideo < activerecord::base belongs_to :video belongs_to :album end
and activeadmin file album album.rb
activeadmin.register album menu :priority => 6, :label => proc{ "album de vidéos" } filter :album_videos permit_params :titre, :description, videos_attributes: [:id, :titre, :_update,:_create] form |f| f.inputs f.inputs "vidéos" f.input :videos, as: :check_boxes, collection: video.all, :member_label => :titre end f.actions end end
album's form displayed, have panel registered videos. when create new album, album registered nil in album_videos table.
anything missing ?
i found solution. juste have add
video_ids: []
to permit_params. mine looks :
permit_params :titre, :description, video_ids: []
ruby-on-rails activerecord ruby-on-rails-4 activeadmin
Comments
Post a Comment