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 foo
s. 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
Post a Comment