I've got a simple class, defined by the following table in a migration: create_table :buzzusers do |t| t.integer :user_id t.string :name t.integer :level, :default => 0
t.timestamps end I usually create it with the following Buzzuser.create(:name => "Bob") which works fine. It appears to save and load fine. I've written the following method within the Buzzuser class model: def promote @level += 1 end This blows up with a nil error when called. More precisely, I get: NoMethodError: You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.+ However, if I'm outside the class, I can access the level variable just fine. If I do bu = Buzzuser.find(1) I can then do bu.level and it returns the correct value for level. What's wrong? I'm assuming I'm missing something basic, but it's pretty confusing. Thanks --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

