2
votes

/usr/local/rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.19/lib/active_support/inflector/methods.rb:124:in `block in constantize': uninitialized constant User (NameError)

I have a users table already in the DB so Im wondering how to fix this problem

1
Do you have User model?Rajdeep Singh
First make sure that you have done all migrations with rake db:migrate. Then, install the devise by rails g devise:install. After that try your command - rails g devise User again.kiddorails
no i havent made a user model yet. I didnt know if I was supposed to generate a scaffold first and then generate a devise or just do one or the other.user3491205
It says the rake was aborted because of an uninitialized constant User. Am I supposed to have a view and controller set up already for user? because as of now I dont have either. Should I just generate a scaffold then have devise overwrite the model ?user3491205

1 Answers

0
votes

Devise should have created the User model for you. It sounds like this did not happen. Try creating the model, something like this...

class User < ActiveRecord::Base
  devise :database_authenticatable, :registerable,
    :recoverable, :rememberable, :trackable, :validatable
end

I would advise against scaffolding the User.

If you need to get the view files, run

rails g devise:views

If you need the controllers (for extending and such) you can reference them here

https://github.com/plataformatec/devise/tree/master/app/controllers/devise

and just create a devise directory within controllers and place the needed controller files within from devise.

Hope this helps.