NameError: Initialized constant User
moussasarr opened this issue · comments
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:in
start'
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:in
run_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:in
require'
from -e:1:in `
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.