Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NameError: Initialized constant User #14

Open
moussasarr opened this issue Feb 25, 2016 · 1 comment
Open

NameError: Initialized constant User #14

moussasarr opened this issue Feb 25, 2016 · 1 comment

Comments

@moussasarr
Copy link

When I try to use the console to view all the users with the command User.all, I get the following error:
2.2.1 :001 > User.all
NameError: uninitialized constant User
from (irb):1
from /Users/msarr/.rvm/gems/ruby-2.2.1/gems/railties- 4.2.5.1/lib/rails/commands/console.rb:110:in start' from /Users/msarr/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5.1/lib/rails/commands/console.rb:9:instart'
from /Users/msarr/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5.1/lib/rails/commands/commands_tasks.rb:68:in console' from /Users/msarr/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5.1/lib/rails/commands/commands_tasks.rb:39:inrun_command!'
from /Users/msarr/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5.1/lib/rails/commands.rb:17:in <top (required)>' from /Users/msarr/Desktop/deployment/YouServe/bin/rails:9:in<top (required)>'
from /Users/msarr/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require' from /Users/msarr/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:inrequire'
from -e:1:in `

'

@BandanaPandey
Copy link

Did you followed these steps::
i) Include gem 'devise' in your Gemfile
ii) Run bundle
iii) rails generate devise:install
iv) rails generate devise User
v) rake db:migrate
Now you will be able to access User.all in your rails c.

Again if you are not able to access it, then make sure that your devise gem should not be inside any group.
Also check your configuration/application.rb and add the line require 'devise' to it, if not present.
Restart your server.
Hope this works for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants