11155
(-- --)
1
Hi,
I have a two models, advert and address.
An advert has one address.
On my advert form I have a nested form of the address. But I only want
to create the nested address depending on the adver kind.
how can I skip the nested attribute validation?
11155
(-- --)
2
I can do it in javascript on the submit event
DK11
(DK)
3
Hi,
I have a two models, advert and address.
An advert has one address.
On my advert form I have a nested form of the address. But I only want
to create the nested address depending on the adver kind.
I think you can use this structure (copied from an app of mine)… you should be able to hack around with the :reject_if to do what you want:
accepts_nested_attributes_for :product_gsa_ldp_line_items,
:reject_if => lambda { |a| a[:first_name].blank? a[:last_name].blank? },
:allow_destroy => true