undefined method `devise' for User (call 'User.connection' to establish a connection):Class 解决方法
参考
rails g devise:install
rails g devise install != rails g devise:install
I ran into this problem as well. Executing rails generate devise install (sic!) there was nothing that seemed not to have worked. The terminal output was:
$ rails g devise install
Running via Spring preloader in process 5422
invoke active_record
create db/migrate/20180306165306_devise_create_installs.rb
create app/models/install.rb
insert app/models/install.rb
route devise_for :installs
But I missed the semicolon. Reverting these changes and then executing rails generate devise:install (note the : between devise and install), everything worked out perfectly. Also you get a much more extensive output:
$ rails g devise:install
Running via Spring preloader in process 5218
create config/initializers/devise.rb
create config/locales/devise.en.yml
===============================================================================
Some setup you must do manually if you haven't yet:
1. Ensure you have defined default url options in your environments files. Here
is an example of default_url_options appropriate for a development environment
in config/environments/development.rb:
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
In production, :host should be set to the actual host of your application.
2. Ensure you have defined root_url to *something* in your config/routes.rb.
For example:
root to: "home#index"
3. Ensure you have flash messages in app/views/layouts/application.html.erb.
For example:
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
4. You can copy Devise views (for customization) to your app by running:
rails g devise:views
===============================================================================
本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。
评论已关闭