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?
gregm
2
I can do it in javascript on the submit event
gregm
3
On Thu, Dec 9, 2010 at 3:00 PM, Greg Ma [email protected] wrote:
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