ruby on rails - Only allow creation of has_many in ActiveAdmin -


i have has_many relation have disabled destroying:

unless f.object.new_record?   f.inputs     f.has_many :foos, allow_destroy: false |foo|       foo.input :bar     end   end end 

currently once i've saved main object , go , edit, can edit created foos. i'd not case , have ability add new ones. how can achieve this?

i can see activeadmin provides allow_destroy , new_record, there isn't analogous allow_edit.

turns out answer staring me in face: new_record?. check whether has_many item new record or not:

f.inputs   f.has_many :foos, allow_destroy: false |foo|     if foo.object.new_record?       foo.input :bar     end   end end 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -