problem with accepts_nested_attributes_for and reject_if

Hi, m using rails 3.0.3 and i m getting problem with reject_if .I just want to check the condition that if all fields of educations table are blank then reject otherwise their values should be stored in database. but actually this saves blank also in database.

class Profile < ActiveRecord::Base

has_many :educations, :dependent => :destroy accepts_nested_attributes_for :educations, :reject_if => proc { |a| a.blank? }, :allow_destroy => true

end

i have tried this also : accepts_nested_attributes_for :educationss, :reject_if => lambda { |a| a.blank? }, :allow_destroy => true

and also : accepts_nested_attributes_for :educationss, :reject_if => lambda { |a| a.all_blank? }, :allow_destroy => true

Can anyone give me an idea of what might be going wrong here?

Thanks kirti

Try accepts_nested_attributes_for :educations, :reject_if => :all_blank, :allow_destroy => true

Garrett Lancaster

still its also not working…

Hmm…works fine for me, sounds like you have a problem somewhere else.

Here's the doc reference:

I would start with the obvious, are you getting the correct values in the params hash? Garrett Lancaster

compose-unknown-contact.jpg

postbox-contact.jpg