Pistos Christou
2006-Mar-23 04:41 UTC
[Rails] 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. :) But if I am misusing ActiveRecord, please correct me... Pistos -- Posted via http://www.ruby-forum.com/.
Rick Olson
2006-Mar-23 06:04 UTC
[Rails] validations.rb of ActiveRecord - bug or misunderstanding?
On 3/22/06, Pistos Christou <jesusrubsyou.5.pistos@geoshell.com> wrote:> 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. :) But if I am misusing > ActiveRecord, please correct me... > > PistosThat''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 :) -- Rick Olson http://techno-weenie.net
Reasonably Related Threads
- eRuby/erb
- ActiveRecord 1.13.2 -> 1.14.0 breaks Postgres connectivity
- update_attribute_with_validation_skipping
- Reading Model data before update
- Problems with "Marco Polo Großer Reiseplaner 2005/2006" - Can't print/Street names not shown correctly/Route not shown