why do I get uninitialized constant Devise name Error when running webrick server?
Solution 1
Check your config/application.rb, you need to add require 'devise' and you should be fine.
Solution 2
In case you are writing an engine which has its own devise config, just add
require 'devise'
on the beginning of devise initializer. In my case I had no devise requirement within application :)
Cheers
Solution 3
Make sure you've listed Devise in your Gemfile and run bundle install
.
Solution 4
I had a similar issue and i found this https://github.com/plataformatec/devise
It says you have to do
rails generate devise:install
Following "Getting Started" on that page got me going
Solution 5
I got an error like that when I had a custom devise controller to override the 'new' method to do some custom stuff, and forgot to use 'super'
Do you have a custom controller?
Addicted
I have no special talents. I am only passionately curious :) Best practices https://github.com/bbatsov/ruby-style-guide https://github.com/bbatsov/rails-style-guide https://github.com/gocardless/angularjs-style-guide http://rubyquicktips.com/post/385665023/fixme-todo-and-optimize-code-comments https://github.com/bbatsov/rubocop https://www.datatables.net/examples/index http://www.phoenixframework.org/docs/up-and-running http://lab.abhinayrathore.com/jquery-standards/ https://contribute.jquery.org/style-guide/js/#naming-conventions
Updated on July 09, 2022Comments
-
Addicted almost 2 years
In my application I have used ruby 1.9.2 and rails 3.0.3 and have also installed Devise gem.The problem begins when I run the Webrick server I get uninitialized constant Devise name Error.
/home/app/Workspace/project/Library_Management/Library_Management/config/initializers/devise.rb:3:in `<top (required)>': uninitialized constant Devise (NameError) from /home/app/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.9/lib/rails/engine.rb:201:in `block (2 levels) in <class:Engine>' from /home/app/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.9/lib/rails/engine.rb:200:in `each' from /home/app/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.9/lib/rails/engine.rb:200:in `block in <class:Engine>' from /home/app/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.9/lib/rails/initializable.rb:25:in `instance_exec' from /home/app/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.9/lib/rails/initializable.rb:25:in `run' from /home/app/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.9/lib/rails/initializable.rb:50:in `block in run_initializers' from /home/app/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.9/lib/rails/initializable.rb:49:in `each' from /home/app/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.9/lib/rails/initializable.rb:49:in `run_initializers' from /home/app/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.9/lib/rails/application.rb:134:in `initialize!' from /home/app/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.9/lib/rails/application.rb:77:in `method_missing' from /home/app/Workspace/project/Library_Management/Library_Management/config/environment.rb:5:in `<top (required)>' from /home/app/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:54:in `require' from /home/app/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:54:in `require' from /home/app/Workspace/project/Library_Management/Library_Management/config.ru:3:in `block in <main>' from /home/app/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.3/lib/rack/builder.rb:46:in `instance_eval' from /home/app/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.3/lib/rack/builder.rb:46:in `initialize' from /home/app/Workspace/project/Library_Management/Library_Management/config.ru:1:in `new' from /home/app/Workspace/project/Library_Management/Library_Management/config.ru:1:in `<main>' from /home/app/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.3/lib/rack/builder.rb:35:in `eval' from /home/app/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.3/lib/rack/builder.rb:35:in `parse_file' from /home/app/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.3/lib/rack/server.rb:162:in `app' from /home/app/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.3/lib/rack/server.rb:253:in `wrapped_app' from /home/app/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.3/lib/rack/server.rb:204:in `start' from /home/app/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.9/lib/rails/commands/server.rb:65:in `start' from /home/app/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.9/lib/rails/commands.rb:30:in `block in <top (required)>' from /home/app/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.9/lib/rails/commands.rb:27:in `tap' from /home/app/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.9/lib/rails/commands.rb:27:in `<top (required)>' from /home/app/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:58:in `require' from /home/app/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:58:in `rescue in require' from /home/app/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
Thanks
-
Addicted almost 13 yearsyes i have listed devise n also ran bundle install but still i am getting the same error..
-
Addicted almost 13 yearsInside the Configuration/application.rb i added the line require 'devise' and was able to fix the problem
-
Automatico over 11 yearsAlso, try "bundle update" as it will be a bit more aggressive in installing updates. It updates all gems with all dependencies which often can help ironing out bugs like this. HAve a look at ryanbigg.com/2011/01/why-you-should-run-bundle-update
-
Eskim0 over 10 yearsI am still having this same problem- strangely however only in my development environment. I just need to restart my development server and that clears it. But after one user login attempt it blows up again. I tried the includes as listed above but they seem like they should not be needed -and they don't help for me.