0

我在让 Rails Admin 与 Heroku 配合使用时遇到问题。管理员登录时出现路由错误,这是错误:

No route matches {:controller=>"rails_admin/main"}

我相信由于我的以下代码而发生此错误application.html.erb

<% if current_admin  %>
    <%= link_to "Admin Dashboard", rails_admin.index_path %>
<% end %>

当我调用rails_admin.index_path. link_to但是,如果我去myurl/admin它,我可以很好地看到管理仪表板。在我本地的开发和生产环境中一切正常。

输出rake routes

             rails_admin        /admin                         RailsAdmin::Engine
             users_index GET    /users/index(.:format)         users#index
              users_show GET    /users/show(.:format)          users#show
                                /user/:id(.:format)            users#show
        new_user_session GET    /users/sign_in(.:format)       devise/sessions#new
            user_session POST   /users/sign_in(.:format)       devise/sessions#create
    destroy_user_session DELETE /users/sign_out(.:format)      devise/sessions#destroy
           user_password POST   /users/password(.:format)      devise/passwords#create
       new_user_password GET    /users/password/new(.:format)  devise/passwords#new
      edit_user_password GET    /users/password/edit(.:format) devise/passwords#edit
                         PUT    /users/password(.:format)      devise/passwords#update
cancel_user_registration GET    /users/cancel(.:format)        devise/registrations#cancel
       user_registration POST   /users(.:format)               devise/registrations#create
   new_user_registration GET    /users/sign_up(.:format)       devise/registrations#new
  edit_user_registration GET    /users/edit(.:format)          devise/registrations#edit
                         PUT    /users(.:format)               devise/registrations#update
                         DELETE /users(.:format)               devise/registrations#destroy
           welcome_index GET    /welcome/index(.:format)       welcome#index
                   songs GET    /songs(.:format)               songs#index
                         POST   /songs(.:format)               songs#create
                new_song GET    /songs/new(.:format)           songs#new
               edit_song GET    /songs/:id/edit(.:format)      songs#edit
                    song GET    /songs/:id(.:format)           songs#show
                         PUT    /songs/:id(.:format)           songs#update
                         DELETE /songs/:id(.:format)           songs#destroy
                    root        /                              welcome#index

Routes for RailsAdmin::Engine:
    dashboard GET         /                                      rails_admin/main#dashboard
        index GET|POST    /:model_name(.:format)                 rails_admin/main#index
          new GET|POST    /:model_name/new(.:format)             rails_admin/main#new
       export GET|POST    /:model_name/export(.:format)          rails_admin/main#export
  bulk_delete POST|DELETE /:model_name/bulk_delete(.:format)     rails_admin/main#bulk_delete
history_index GET         /:model_name/history(.:format)         rails_admin/main#history_index
  bulk_action POST        /:model_name/bulk_action(.:format)     rails_admin/main#bulk_action
         show GET         /:model_name/:id(.:format)             rails_admin/main#show
         edit GET|PUT     /:model_name/:id/edit(.:format)        rails_admin/main#edit
       delete GET|DELETE  /:model_name/:id/delete(.:format)      rails_admin/main#delete
 history_show GET         /:model_name/:id/history(.:format)     rails_admin/main#history_show
  show_in_app GET         /:model_name/:id/show_in_app(.:format) rails_admin/main#show_in_app
4

1 回答 1

1

我的解决方案是改变

rails_admin.index_path

rails_admin.dashboard_path

不知道为什么它在生产中不起作用,但这会起作用。

于 2012-03-04T04:22:20.733 回答