Forum: Ruby on Rails validations.rb of ActiveRecord - bug or misunderstanding?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Pistos C. (Guest)
on 2006-03-23 06:41
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/activerec...
), 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.  :)  But if I am misusing
ActiveRecord, please correct me...

Pistos
Rick O. (Guest)
on 2006-03-23 08:04
(Received via mailing list)
On 3/22/06, Pistos C. <removed_email_address@domain.invalid> wrote:
>       save(false)
> program runs as expected.
>
> In case this is a bug, here is the report.  :)  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/activerec...

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

--
Rick O.
http://techno-weenie.net
This topic is locked and can not be replied to.