简体   繁体   中英

heroku uninitialized constant user

I have a rails application using devise for authentication. It works when deployed locally but when push to Heroku I get this error

2014-07-03T14:20:17.235816+00:00 app[web.1]: /app/app/controllers/users_controller.rb:1:in `<top (required)>': uninitialized constant Users (NameError)

Here is the file it is referring to

class Users::SessionsController < Devise::SessionsController
    before_create :create_associated_records

    ROLES = [ROLE_STUDENT = 'student', ROLE_GRADUATE = 'graduate', 
         ROLE_INSTITUTIONAL_ADMIN = 'role_recruiter', ROLE_ADMIN = 'admin']

    def create
        @user = User.create(user_params)
    end

    private

    def user_params
        params.require(:user).permit(:avatar)
    end

end

Thank you.

I believe you should either move

/app/app/controllers/users_controller.rb

to

/app/app/controllers/users/users_controller.rb

or change

class Users::SessionsController < Devise::SessionsController 

to

class SessionsController < Devise::SessionsController

This is due to the :: , which denotes a location. Users::SessionsController would be looking for ./Users/SessionController , which is a relative path to the current tree level ( controllers ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM