I have code like:
@notifications = Notification.find_all_by_user_id(@user.id, :order=>'deliver_by DESC', :conditions=>"deliver_by >= '#{Date.today.to_s(:db)}'")
logger.info @upcoming_reminders[0].inspect
logger.info @upcoming_reminders[0].class
logger.info @upcoming_reminders[0].id
logger.info "--------------------------"
The logged result is
#<TwitterNotification id: 1, user_id: 3, message: "Testing", deliver_by: "2009-10-30 16:00:00", created_at: "2009-10-13 12:00:45", updated_at: "2009-10-28 20:01:03", processed_at: "2009-10-13 20:00:06", type: "TwitterNotification">
TwitterNotification
ArgumentError (wrong number of arguments (1 for 0)):
app/controllers/reminders_controller.rb:57:in `get_reminders'
As you can see, I get an argument error when trying to access the id. This actually occurs when I try to access any attribute. This may be a case of staring at the computer too long but I haven't been able to figure it out. Any ideas? Note that TwitterNotification is a subclass of Notification implemented using Single Table Inheritance.
Thanks!
UPDATE
I made a little progress, this works fine:
logger.info @upcoming_reminders[0][:id]
So accessing active record object attributes with a symbol works fine but dot notation does not. Any idea why?
Ok not a case of staring at my computer too long. I created a method called send in my model which does not seem to be allowed.