`method_missing': undefined method `devise' for User (call 'User.connection' to establish a connection)

前端 未结 9 1546
梦如初夏
梦如初夏 2020-12-20 11:29

I am new to Ruby on Rails and am trying to make my first application. I am having issues though anytime I run any rails generate command. I get the following er

9条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-20 11:58

    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:
    
             

    <%= notice %>

    <%= alert %>

    4. You can copy Devise views (for customization) to your app by running: rails g devise:views ===============================================================================

提交回复
热议问题