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