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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -