views:

63

answers:

1

I currently have a nested forms model. The nested forms for the paperclip attachments work fi and don't populate the DB with blanks, but another one I have for quotes always saves one blank quote along with my main model when I create a new one. How can I just have it silently fail and bypass writing this to the db? It's an optional field so I don't want to give them an error.

+4  A: 

Use the following option on accepts_nested_attributes

accepts_nested_attributes_for :quotes, :reject_if => :all_blank

If you want to be more specific about when the record is considered blank, :reject_if also can take a proc.

mckeed