I'm running Rails 1.2.1 with Ruby 1.8.4. The following script/console session reveals the problem one of my models is suffering: >> r=Reminder.new => #<Reminder:0xb73cf3d4 @new_record=true, @attributes={"receiver_id"=>nil, "sent_date"=>nil, "appt_date"=>nil, "notify"=>nil}> >> r.valid? ArgumentError: wrong number of arguments (1 for 0) from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/callbacks.rb:328:in `notify' from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/callbacks.rb:328:in `callback' from /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/callbacks.rb:301:in `valid?' from (irb):2 Here is my model: class Reminder < ActiveRecord::Base belongs_to(:receiver) validates_presence_of(:appt_date) validates_numericality_of(:notify) validates_presence_of(:receiver_id) end Here is my migration: def self.up create_table :reminders do |t| t.column(:appt_date, :datetime, :null => false) t.column(:notify, :integer, :null => false) t.column(:sent_date, :datetime) t.column(:receiver_id, :integer, :null => false) end add_index(:reminders, :receiver_id) end What gives? `r.valid?` should return false. I have similar, more complex setups with other models using validates_presence_of and validates_numericality_of and they do not throw ArgumentErrors. As expected, if I comment out the validates_* method calls the problem goes away. Any help is greatly appreciated! Thanks in advance ;)
on 2007-02-11 17:37
on 2007-02-12 13:25
On 2/12/07, Chris Stump <rails-mailing-list@andreas-s.net> wrote: > ArgumentError: wrong number of arguments (1 for 0) > from > /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/callbacks.rb:328:in > `notify' > ... Ouch! callbacks.rb:328 shows that #notify is an internally used private method. Your notify attribute is colliding with this. Try choosing another name (as unsatisfying as that solution probably seems...).
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.