Devise_for缺少路线

时间:2015-03-30 14:16:11

标签: ruby-on-rails devise

我有两个设计模型,DriverEmployer

devise_for:雇主,管制员:{会话:"雇主/会议",     注册:"雇主/注册",     密码:'雇主/密码' }

devise_for:驱动程序,控制器:{sessions:" drivers / sessions",     注册:"司机/注册",     密码:'驱动程序/密码' }

在我最近做出更改后,devise_for:drivers尚未创建注册路由:

> rake routes:

           new_employer_session GET        /employers/sign_in(.:format)                                employers/sessions#new
               employer_session POST       /employers/sign_in(.:format)                                employers/sessions#create
       destroy_employer_session DELETE     /employers/sign_out(.:format)                               employers/sessions#destroy
              employer_password POST       /employers/password(.:format)                               employers/passwords#create
          new_employer_password GET        /employers/password/new(.:format)                           employers/passwords#new
         edit_employer_password GET        /employers/password/edit(.:format)                          employers/passwords#edit
                                PATCH      /employers/password(.:format)                               employers/passwords#update
                                PUT        /employers/password(.:format)                               employers/passwords#update
   cancel_employer_registration GET        /employers/cancel(.:format)                                 employers/registrations#cancel
          employer_registration POST       /employers(.:format)                                        employers/registrations#create
      new_employer_registration GET        /employers/sign_up(.:format)                                employers/registrations#new
     edit_employer_registration GET        /employers/edit(.:format)                                   employers/registrations#edit
                                PATCH      /employers(.:format)                                        employers/registrations#update
                                PUT        /employers(.:format)                                        employers/registrations#update
                                DELETE     /employers(.:format)                                        employers/registrations#destroy
             new_driver_session GET        /drivers/sign_in(.:format)                                  drivers/sessions#new
                 driver_session POST       /drivers/sign_in(.:format)                                  drivers/sessions#create
         destroy_driver_session DELETE     /drivers/sign_out(.:format)                                 drivers/sessions#destroy
                driver_password POST       /drivers/password(.:format)                                 drivers/passwords#create
            new_driver_password GET        /drivers/password/new(.:format)                             drivers/passwords#new
           edit_driver_password GET        /drivers/password/edit(.:format)                            drivers/passwords#edit
                                PATCH      /drivers/password(.:format)                                 drivers/passwords#update
                                PUT        /drivers/password(.:format)                                 drivers/passwords#update

routes.rb中没有任何异常,所有初始化程序都是相同的。

这次改变意外地发生了rails g active_admin:install Driver(第二次,我几周前做错了)。这产生了这个:

      invoke  devise
    generate    No need to install devise, already done.
      invoke    active_record
      create      db/migrate/20150330130706_add_devise_to_drivers.rb
      insert      app/models/driver.rb
       route    devise_for :drivers
        gsub    app/models/driver.rb
        gsub    config/routes.rb
      insert    db/migrate/20150304171112_devise_create_drivers.rb
    conflict  config/initializers/active_admin.rb
Overwrite /Users/Will/Google Drive/Driver Hunt/Code/driverhunt2/config/initializers/active_admin.rb? (enter "h" for help) [Ynaqdh] n
        skip  config/initializers/active_admin.rb
       exist  app/admin
   identical  app/admin/dashboard.rb
      create  app/admin/driver.rb
      insert  config/routes.rb
    generate  active_admin:assets
rDEPRECATION WARNING: Support for Rails < 4.1.0 will be dropped. (called from <top (required)> at /Users/Will/.rvm/gems/ruby-2.0.0-p481@railstutorial_rails_4_0/bundler/gems/activeadmin-078f234288a1/lib/active_admin.rb:8)
ake db:migrate   identical  app/assets/javascripts/active_admin.js.coffee
   identical  app/assets/stylesheets/active_admin.css.scss
   identical  db/migrate/20150309131947_create_active_admin_comments.rb

究竟发生了什么?为什么devise_for坏了?

1 个答案:

答案 0 :(得分:0)

解决。解决方案是再次运行rails generate devise Driver

这会创建:

  invoke  active_record
  create    db/migrate/20150330141801_add_devise_to_drivers.rb
  insert    app/models/driver.rb
   route  devise_for :drivers

然后我删除了迁移。固定的。

背景究竟是怎么回事? insert app/models/driver.rbroute devise_for :drivers在做什么?它们似乎没有更改我的应用程序中的任何文件。