I’ve been working through Hartl’s excellent RoR (3.2) tutorial (and deploying to Heroku throughout) and have become stumped why the Heroku version is no longer mirroring the behavior of the locally hosted app.
I’m at the end of section 7.4.4: http://ruby.railstutorial.org/chapters/sign-up?version=3.2#top
My locally hosted app passes all tests and is able to both create a new user and give appropriate error messages when user/email/password input is incorrect or out of spec. On the Heroku deployment of the app I am getting neither success in creating a user nor correct error pages as there seems to be something wrong with the password digest function in that version. I am taken to a generic Heroku “We’re sorry, but something went wrong” page.
The “heroku logs” command gives me:
Started POST "/users" for 97.81.107.108 at 2012-04-10 19:41:17 +0000create’
2012-04-10T19:41:17+00:00 app[web.1]: Processing by UsersController#create as HTML
2012-04-10T19:41:17+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "authenticity_token"=>"0jnDCpFnVq9fd/v1lgLNB7g0wHuXGi5bocTD3SINRzc=", "user"=>{"name"=>"helloq", "email"=>"this@this.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Create my account"}
2012-04-10T19:41:17+00:00 app[web.1]:
2012-04-10T19:41:17+00:00 app[web.1]: app/controllers/users_controller.rb:12:in
2012-04-10T19:41:17+00:00 app[web.1]:
2012-04-10T19:41:17+00:00 app[web.1]: NoMethodError (undefined method password_digest=' for #<User:0x0000000229e9e0>):new’
2012-04-10T19:41:17+00:00 app[web.1]:
2012-04-10T19:41:17+00:00 heroku[router]: POST simple-sword-1851.herokuapp.com/users dyno=web.1 queue=0 wait=0ms service=128ms status=500 bytes=643
2012-04-10T19:41:17+00:00 app[web.1]: Completed 500 Internal Server Error in 104ms
2012-04-10T19:41:17+00:00 app[web.1]: app/controllers/users_controller.rb:12:in
Why would I get a NoMethodError when the password_digest method is functioning properly on the local deployment? I’ve checked with git that my local version and the remote heroku version are the same, and I’ve made sure to migrate the database and restart the app.
Thanks for any suggestions!
I am working through the tutorial as well and just about done. I want to follow up on Matthias’s comment. Looking at chapter 7, he doesn’t tell you how to reset the DB on Heroku yet. If you want to completely clear the DB and re-run the migrations do this:
I had some problems occasionally when I messed up something in the migration.