Rails with Devise, works fine on localhost, fails on Heroku

Delos Chang

In my Heroku logs:

Processing by UsersController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"YsNr73owFsrgM4HX5QDq304ot4gBhGBx1SlOkq+hAxg=", "user"=>{"housing_type"=>"Sublets / Shares", "area_id"=>"1", "subarea_id"=>"", "rent_min"=>"", "rent_max"=>"", "bedroom_min"=>"0", "cat"=>"0", "dog"=>"0", "pic"=>"0", "email"=>"[email protected]"}, "commit"=>"Start your Free Trial: 10 leads"}

app/controllers/users_controller.rb:16:in `create'
Completed 500 Internal Server Error in 6ms
NameError (undefined local variable or method `confirmed_at' for #<User:0x000000048a57b0>):
     app/models/user.rb:81:in `password_required?'

So it fails at line 16 in #create which is the @user.save part:

@user = User.new(params[:user])
if @user.save

And password_required method is declared for Devise in the user.rb file:

  def password_required?
    super if confirmed?
  end

I have already run rake db:migrate and check the migration status to make sure that it has completed on Heroku. I have also run

 heroku run rails console
 irb(main):012:0> User
 => User(id: integer, email: string, trial_count_left: integer, created_at: datetime, updated_at: datetime, rent_min: integer, rent_max: integer, bedroom_min: integer, cat: boolean, dog: boolean, pic: boolean, housing_type: string, subarea_id: integer, area_id: integer, encrypted_password: string, reset_password_token: string, reset_password_sent_at: datetime, remember_created_at: datetime, sign_in_count: integer, current_sign_in_at: datetime, last_sign_in_at: datetime, current_sign_in_ip: string, last_sign_in_ip: string, confirmation_token: string, confirmed_at: datetime, confirmation_sent_at: datetime, unconfirmed_email: string)

which has confirmed_at

Finally, I've also run through

 heroku run rails console
 irb(main):012:0> User.new( < manual params here >).save

And everything works fine through the interpreter.

What could be going wrong? I'd rather not reset the entire database as it is a production database.

Thanks

Delos Chang

For some reason, "heroku restart" did the trick. I'm not sure what was happening in the background, technically speaking but I'm glad it's working now. I will look up Heroku documentations to see if I can pinpoint the underlying technical reason for this.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Rails ActiveAdmin not Working on Heroku but works on Localhost

Jetty CORS works fine on Heroku with cometd but fails when cometd returns

Rails 4 + Devise + Heroku

Rails 5 + Heroku: Assets are not loaded in production, but works in localhost

Can not create user with Rails app on heroku, but works perfect on localhost

CSS Works fine on Localhost but not on Server

Drakma and Dexador both fails at USocket call while requesting localhost only, requesting the internet works fine

Django app works on localhost but not Heroku

Project works fine on localhost but the build gets an issue

Twitter APIs not working on hosting [Works fine on localhost]

400 Bad Request, works fine localhost

Stan code works fine but fails on Linux cluster

sbt run works fine but running jar fails

go build works fine but go run fails

getResourceAsStream() works fine in eclipse but fails in jar

Query works fine in browser but fails in CLI

Adding textfields works fine but removing textfields fails

Running a binary directly works fine, but fails with execve

jquery works on second click only (but works fine in localhost...)

Heroku and ruby on rails: Deploy works, but running app fails do to usual sqlite3 error

Heroku/Rails/Devise: The change you wanted was rejected

mail not sending using devise, heroku, and postmark on rails

Deploying rails app to heroku with devise gem

Stripe Payment Works on LocalHost but Does not work on Heroku

Loading dynamic webpage with Puppeteer works on localhost but not Heroku

My worker Celery works in localhost but not in heroku

Chartkick works on localhost but displays "loading" on heroku

Trix editor isn't working in Heroku, but working fine on localhost

500 Internal Server Error, but works fine on localhost - $mysqli = new mysqli