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 L.



You received this message because you are subscribed to the Google
Groups “Ruby on Rails: Talk” group.

To post to this group, send email to
[email protected].

To unsubscribe from this group, send email to
[email protected].

For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.

still its also not working…

On Mon, Jan 24, 2011 at 3:28 PM, Garrett L. <

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 L.