3

我已经安装了炼油厂/,我正在尝试将它集成到我现有的应用程序中。(我也是 Rails 的新手:)

我已经覆盖views/refinery/_header.html.erb将登录/注销/编辑配置文件菜单添加到页面顶部:

<% if current_user %>
    <%= link_to current_user.email, :controller => "users", :action => :edit, :id => current_user.id %>
    <%= link_to "Log out", main_app.logout_url %>
<% else %>
    <%= link_to "Sign Up", main_app.signup_url %> or
    <%= link_to "Log In", main_app.login_url %>
<% end %>

但是,此代码在加载时会生成错误:

No route matches {:controller=>"refinery/users", :action=>"edit", :id=>"a7ruusdt"}

问题

  1. 覆盖 _header.html.erb 是实现此目标的最佳实践吗?
  2. 如果是这样,我如何从 Refinery 标头中访问我的应用程序的控制器?换句话说,我如何从引擎中访问主应用程序的控制器?

这是rake routes输出:

$ rake routes
       logout GET    /logout(.:format)             sessions#destroy
        login GET    /login(.:format)              sessions#new
       signup GET    /signup(.:format)             users#new
        users GET    /users(.:format)              users#index
              POST   /users(.:format)              users#create
     new_user GET    /users/new(.:format)          users#new
    edit_user GET    /users/:id/edit(.:format)     users#edit
         user GET    /users/:id(.:format)          users#show
              PUT    /users/:id(.:format)          users#update
              DELETE /users/:id(.:format)          users#destroy
     sessions GET    /sessions(.:format)           sessions#index
              POST   /sessions(.:format)           sessions#create
  new_session GET    /sessions/new(.:format)       sessions#new
 edit_session GET    /sessions/:id/edit(.:format)  sessions#edit
      session GET    /sessions/:id(.:format)       sessions#show
              PUT    /sessions/:id(.:format)       sessions#update
              DELETE /sessions/:id(.:format)       sessions#destroy
    followers GET    /followers(.:format)          followers#index
              POST   /followers(.:format)          followers#create
 new_follower GET    /followers/new(.:format)      followers#new
edit_follower GET    /followers/:id/edit(.:format) followers#edit
     follower GET    /followers/:id(.:format)      followers#show
              PUT    /followers/:id(.:format)      followers#update
              DELETE /followers/:id(.:format)      followers#destroy
     refinery        /                             Refinery::Core::Engine

Routes for Refinery::Core::Engine:
                                       /system/resources/*dragonfly(.:format)       <Dragonfly::App name=:refinery_resources >
        insert_admin_resources GET     /refinery/resources/insert(.:format)         refinery/admin/resources#insert
               admin_resources GET     /refinery/resources(.:format)                refinery/admin/resources#index
                               POST    /refinery/resources(.:format)                refinery/admin/resources#create
            new_admin_resource GET     /refinery/resources/new(.:format)            refinery/admin/resources#new
           edit_admin_resource GET     /refinery/resources/:id/edit(.:format)       refinery/admin/resources#edit
                admin_resource PUT     /refinery/resources/:id(.:format)            refinery/admin/resources#update
                               DELETE  /refinery/resources/:id(.:format)            refinery/admin/resources#destroy
                                       /system/images/*dragonfly(.:format)          <Dragonfly::App name=:refinery_images >
           insert_admin_images GET     /refinery/images/insert(.:format)            refinery/admin/images#insert
                  admin_images GET     /refinery/images(.:format)                   refinery/admin/images#index
                               POST    /refinery/images(.:format)                   refinery/admin/images#create
               new_admin_image GET     /refinery/images/new(.:format)               refinery/admin/images#new
              edit_admin_image GET     /refinery/images/:id/edit(.:format)          refinery/admin/images#edit
                   admin_image PUT     /refinery/images/:id(.:format)               refinery/admin/images#update
                               DELETE  /refinery/images/:id(.:format)               refinery/admin/images#destroy
               admin_dashboard GET     /refinery/dashboard(.:format)                refinery/admin/dashboard#index
 admin_disable_upgrade_message         /refinery/disable_upgrade_message(.:format)  refinery/admin/dashboard#disable_upgrade_message
                                       /system/resources/*dragonfly(.:format)       <Dragonfly::App name=:refinery_resources >
                               GET     /refinery/resources/insert(.:format)         refinery/admin/resources#insert
                               GET     /refinery/resources(.:format)                refinery/admin/resources#index
                               POST    /refinery/resources(.:format)                refinery/admin/resources#create
                               GET     /refinery/resources/new(.:format)            refinery/admin/resources#new
                               GET     /refinery/resources/:id/edit(.:format)       refinery/admin/resources#edit
                               PUT     /refinery/resources/:id(.:format)            refinery/admin/resources#update
                               DELETE  /refinery/resources/:id(.:format)            refinery/admin/resources#destroy
                                       /system/images/*dragonfly(.:format)          <Dragonfly::App name=:refinery_images >
                               GET     /refinery/images/insert(.:format)            refinery/admin/images#insert
                               GET     /refinery/images(.:format)                   refinery/admin/images#index
                               POST    /refinery/images(.:format)                   refinery/admin/images#create
                               GET     /refinery/images/new(.:format)               refinery/admin/images#new
                               GET     /refinery/images/:id/edit(.:format)          refinery/admin/images#edit
                               PUT     /refinery/images/:id(.:format)               refinery/admin/images#update
                               DELETE  /refinery/images/:id(.:format)               refinery/admin/images#destroy
               admin_dashboard GET     /refinery/dashboard(.:format)                refinery/admin/dashboard#inde
 admin_disable_upgrade_message         /refinery/disable_upgrade_message(.:format)  refinery/admin/dashboard#disable_upgrade_message
                                       /system/resources/*dragonfly(.:format)       <Dragonfly::App name=:refinery_resources >
                               GET     /refinery/resources/insert(.:format)         refinery/admin/resources#insert
                               GET     /refinery/resources(.:format)                refinery/admin/resources#index
                               POST    /refinery/resources(.:format)                refinery/admin/resources#create
                               GET     /refinery/resources/new(.:format)            refinery/admin/resources#new
                               GET     /refinery/resources/:id/edit(.:format)       refinery/admin/resources#edit
                               PUT     /refinery/resources/:id(.:format)            refinery/admin/resources#update
                               DELETE  /refinery/resources/:id(.:format)            refinery/admin/resources#destroy
                                       /system/images/*dragonfly(.:format)          <Dragonfly::App name=:refinery_images >
                               GET     /refinery/images/insert(.:format)            refinery/admin/images#insert
                               GET     /refinery/images(.:format)                   refinery/admin/images#index
                               POST    /refinery/images(.:format)                   refinery/admin/images#create
                               GET     /refinery/images/new(.:format)               refinery/admin/images#new
                               GET     /refinery/images/:id/edit(.:format)          refinery/admin/images#edit
                               PUT     /refinery/images/:id(.:format)               refinery/admin/images#update
                               DELETE  /refinery/images/:id(.:format)               refinery/admin/images#destroy
               admin_dashboard GET     /refinery/dashboard(.:format)                refinery/admin/dashboard#index
 admin_disable_upgrade_message         /refinery/disable_upgrade_message(.:format)  refinery/admin/dashboard#disable_upgrade_message
                          root GET     /                                            refinery/pages#home
                 preview_pages POST    /pages/preview(.:format)                     refinery/pages#preview
                  preview_page GET|PUT /pages/*path/preview(.:format)               refinery/pages#preview
                          page GET     /pages/:id(.:format)                         refinery/pages#show
                         admin GET     /refinery/pages/*path/edit(.:format)         refinery/admin/pages#edit
          admin_children_pages GET     /refinery/pages/*path/children(.:format)     refinery/admin/pages#children
                               PUT     /refinery/pages/*path(.:format)              refinery/admin/pages#update
                               DELETE  /refinery/pages/*path(.:format)              refinery/admin/pages#destroy
  update_positions_admin_pages POST    /refinery/pages/update_positions(.:format)   refinery/admin/pages#update_positions
                   admin_pages GET     /refinery/pages(.:format)                    refinery/admin/pages#index
                               POST    /refinery/pages(.:format)                    refinery/admin/pages#create
                new_admin_page GET     /refinery/pages/new(.:format)                refinery/admin/pages#new
               edit_admin_page GET     /refinery/pages/:id/edit(.:format)           refinery/admin/pages#edit
                    admin_page PUT     /refinery/pages/:id(.:format)                refinery/admin/pages#update
                               DELETE  /refinery/pages/:id(.:format)                refinery/admin/pages#destroy
   link_to_admin_pages_dialogs GET     /refinery/pages_dialogs/link_to(.:format)    refinery/admin/pages_dialogs#link_to
  test_url_admin_pages_dialogs GET     /refinery/pages_dialogs/test_url(.:format)   refinery/admin/pages_dialogs#test_url
test_email_admin_pages_dialogs GET     /refinery/pages_dialogs/test_email(.:format) refinery/admin/pages_dialogs#test_email
              admin_page_parts POST    /refinery/page_parts(.:format)               refinery/admin/page_parts#create
           new_admin_page_part GET     /refinery/page_parts/new(.:format)           refinery/admin/page_parts#new
               admin_page_part DELETE  /refinery/page_parts/:id(.:format)           refinery/admin/page_parts#destroy
     new_refinery_user_session GET     /refinery/users/login(.:format)              refinery/sessions#new
         refinery_user_session POST    /refinery/users/login(.:format)              refinery/sessions#create
 destroy_refinery_user_session DELETE  /refinery/users/logout(.:format)             refinery/sessions#destroy
        refinery_user_password POST    /refinery/users/password(.:format)           refinery/passwords#create
    new_refinery_user_password GET     /refinery/users/password/new(.:format)       refinery/passwords#new
   edit_refinery_user_password GET     /refinery/users/password/edit(.:format)      refinery/passwords#edit
                               PUT     /refinery/users/password(.:format)           refinery/passwords#update
     new_refinery_user_session GET     /refinery/login(.:format)                    refinery/sessions#new
 destroy_refinery_user_session GET     /refinery/logout(.:format)                   refinery/sessions#destroy
new_refinery_user_registration GET     /refinery/users/register(.:format)           refinery/users#new
    refinery_user_registration POST    /refinery/users/register(.:format)           refinery/users#create
                     wymiframe GET     /wymiframe(/:id)(.:format)                   refinery/fast#wymiframe
                       message GET     /refinery/message(.:format)                  refinery/fast#message
                    admin_root         /refinery(.:format)                          refinery/admin/dashboard#index
                  admin_dialog GET     /refinery/dialogs/:id(.:format)              refinery/admin/dialogs#show
refinery_update_menu_positions         /refinery/update_menu_positions(.:format)    refinery/admin/core#update_plugin_positions
                               GET     /sitemap.xml(.:format)                       refinery/sitemap#index {:format=>"xml"}
                   admin_users GET     /refinery/users(.:format)                    refinery/admin/users#index
                               POST    /refinery/users(.:format)                    refinery/admin/users#create
                new_admin_user GET     /refinery/users/new(.:format)                refinery/admin/users#new
               edit_admin_user GET     /refinery/users/:id/edit(.:format)           refinery/admin/users#edit
                    admin_user PUT     /refinery/users/:id(.:format)                refinery/admin/users#update
                               DELETE  /refinery/users/:id(.:format)                refinery/admin/users#destroy
                                       /refinery/*path(.:format)                    refinery/admin/base#error_404
                               GET     /refinery/users(.:format)                    refinery/admin/users#index
                               POST    /refinery/users(.:format)                    refinery/admin/users#create
                               GET     /refinery/users/new(.:format)                refinery/admin/users#new
                               GET     /refinery/users/:id/edit(.:format)           refinery/admin/users#edit
                               PUT     /refinery/users/:id(.:format)                refinery/admin/users#update
                               DELETE  /refinery/users/:id(.:format)                refinery/admin/users#destroy
                                       /refinery/*path(.:format)                    refinery/admin/base#error_404
               marketable_page GET     /*path(.:format)                             refinery/pages#show
                               GET     /refinery/users(.:format)                    refinery/admin/users#index
                               POST    /refinery/users(.:format)                    refinery/admin/users#create
                               GET     /refinery/users/new(.:format)                refinery/admin/users#new
                               GET     /refinery/users/:id/edit(.:format)           refinery/admin/users#edit
                               PUT     /refinery/users/:id(.:format)                refinery/admin/users#update
                               DELETE  /refinery/users/:id(.:format)                refinery/admin/users#destroy
                                       /refinery/*path(.:format)                    refinery/admin/base#error_404
                               GET     /refinery/users(.:format)                    refinery/admin/users#index
                               POST    /refinery/users(.:format)                    refinery/admin/users#create
                               GET     /refinery/users/new(.:format)                refinery/admin/users#new
                               GET     /refinery/users/:id/edit(.:format)           refinery/admin/users#edit
                               PUT     /refinery/users/:id(.:format)                refinery/admin/users#update
                               DELETE  /refinery/users/:id(.:format)                refinery/admin/users#destroy
                                       /refinery/*path(.:format)                    refinery/admin/base#error_404

注意:我已经推出了自己的身份验证,它没有与 Refinery 的集成,我也不希望它集成。

4

1 回答 1

1

您可以在路由之前使用 main_app 和“engine_name”来访问您想要的。假设您有一个名为 Foo 的引擎,例如 Foo::Engine:

main_app.pages_url
foo.pages_url
于 2013-02-02T18:43:02.050 回答