Validations.rb of ActiveRecord - bug or misunderstanding?

Either I’m not understanding how things are used, or this might be a bug
in ActiveRecord. I’m using version 1.13.2.

In my version of activerecord/lib/active_record/validations.rb (the svn
trunk version is browsable at
http://dev.rubyonrails.org/browser/trunk/activerecord/lib/active_record/validations.rb
), I have:

def update_attribute_with_validation_skipping(name, value)
  send(name.to_s + '=', value)
  save(false)
end

Which results in this error when I try to update_attribute:

wrong number of arguments (1 for 0)
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/validations.rb:720:in
`save’

I don’t think there are any save methods which take an argument, so I
removed the “(false)” part in both places it appears in the file, and my
program runs as expected.

In case this is a bug, here is the report. :slight_smile: But if I am misusing
ActiveRecord, please correct me…

Pistos

On 3/22/06, Pistos C. [email protected] wrote:

  save(false)

program runs as expected.

In case this is a bug, here is the report. :slight_smile: But if I am misusing
ActiveRecord, please correct me…

Pistos

That’s definitely a bug somewhere. Validations override #save so that
it takes a boolean telling it to validate or not:

http://dev.rubyonrails.org/browser/trunk/activerecord/lib/active_record/validations.rb#L719

The reason why yours isn’t working is a mystery. It would be very
apparent if this broke in ActiveRecord :slight_smile:


Rick O.
http://techno-weenie.net