Matthew H
Matthew H

Reputation: 5879

Rails not picking up model attribute despite column EXISTING in table

==  AddIpToTutorials: migrating ===============================================
-- add_column(:tutorials, :ip_address, :string)
   -> 0.0022s
==  AddIpToTutorials: migrated (0.0022s) ======================================

>> t = Tutorial.new
..
>> t.ip_address
NoMethodError: undefined method `ip_address' for #<Tutorial:0x2b3b35f5a690>

... What gives? >______>

Upvotes: 0

Views: 315

Answers (2)

McStretch
McStretch

Reputation: 20645

I recently ran into the exact same problem, and instead of making a separate migration I would instead suggest running the command:

heroku restart

After running the above command heroku picked up the changes and my app worked as expected. Try this before going through the pain of rolling back a migration, deleting it, and then creating a new one.

Upvotes: 1

Matthew H
Matthew H

Reputation: 5879

Ended up making a seperate migration and doing the same thing again.

Crumby, but it works...

Upvotes: 0

Related Questions