ruby on rails - nested attributes create reference only if already present instead of creating new entry -
i newb rails. accepts_nested_attributes_for
creates new entry every time how can check if entry present , if present want reference stored in join table.
class user < activerecord::base has_and_belongs_to_many :categories accepts_nested_attributes_for :categories, :allow_destroy => true alias_method :categories=, :categories_attributes= end
and
class category < activerecord::base has_and_belongs_to_many :users end
how can this? please me.
Comments
Post a Comment