设计路线助手 "new_user_registration_path" 在 RefineryCMS 路线中不可用

Devise route helper "new_user_registration_path" not available in RefineryCMS route

我们刚刚使用 Rails 4 和 Ruby 2.1 以及 RefineryCMS 建立了一个新站点。有些网站由 Devise 处理,例如您可以像这样去 URL 注册:

http://0.0.0.0:3000/users/sign_up

如果成功,您将被重定向到这里:

http://0.0.0.0:3000/profile/search

此时我们遇到了错误。我们不希望登录表单出现在注册页面上,因此在 application.html.erb 中我们有:

<% unless current_page?(new_user_registration_path) %>
  <%= render "/login" %>
<% end %>

上运行良好
http://0.0.0.0:3000/users/sign_up

但这里:

http://0.0.0.0:3000/profile/search

我们得到:

NameError in Refinery::Pages#show

undefined local variable or method `new_user_registration_path'

如何确保 new_user_registration_path 等辅助函数在全球范围内可用?

所有路线:

bundle exec rake routes
                  Prefix Verb   URI Pattern                    Controller#Action
        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
                         PATCH  /users/password(.:format)      devise/passwords#update
                         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
                         PATCH  /users(.:format)               devise/registrations#update
                         PUT    /users(.:format)               devise/registrations#update
                         DELETE /users(.:format)               devise/registrations#destroy
                    root GET    /                              intro#join
      authenticated_root GET    /                              member#profile
                benefits GET    /intro/benefits(.:format)      intro#benefits
                progress GET    /intro/progress(.:format)      intro#progress
                    join GET    /intro/join(.:format)          intro#join
                  search GET    /member/search(.:format)       member#search
                 library GET    /member/library(.:format)      member#library
                refinery        /                              Refinery::Core::Engine

Routes for Refinery::Core::Engine:
                       videos_videos GET    /videos(.:format)                           refinery/videos/videos#index
                        videos_video GET    /videos/:id(.:format)                       refinery/videos/videos#show
update_positions_videos_admin_videos POST   /refinery/videos/update_positions(.:format) refinery/videos/admin/videos#update_positions
                 videos_admin_videos GET    /refinery/videos(.:format)                  refinery/videos/admin/videos#index
                                     POST   /refinery/videos(.:format)                  refinery/videos/admin/videos#create
              new_videos_admin_video GET    /refinery/videos/new(.:format)              refinery/videos/admin/videos#new
             edit_videos_admin_video GET    /refinery/videos/:id/edit(.:format)         refinery/videos/admin/videos#edit
                  videos_admin_video PATCH  /refinery/videos/:id(.:format)              refinery/videos/admin/videos#update
                                     PUT    /refinery/videos/:id(.:format)              refinery/videos/admin/videos#update
                                     DELETE /refinery/videos/:id(.:format)              refinery/videos/admin/videos#destroy
                           wymiframe GET    /wymiframe(/:id)(.:format)                  refinery/fast#wymiframe
                                root GET    /                                           refinery/pages#home
                                page GET    /pages/:id(.:format)                        refinery/pages#show
           pages_admin_preview_pages POST   /refinery/pages/preview(.:format)           refinery/pages/admin/preview#show
            pages_admin_preview_page PATCH  /refinery/pages/preview/*path(.:format)     refinery/pages/admin/preview#show
                     admin_edit_page GET    /refinery/pages/*path/edit(.:format)        refinery/admin/pages#edit
                admin_children_pages GET    /refinery/pages/*path/children(.:format)    refinery/admin/pages#children
                   admin_update_page PATCH  /refinery/pages/*path(.:format)             refinery/admin/pages#update
                   admin_delete_page 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 PATCH  /refinery/pages/:id(.:format)               refinery/admin/pages#update
                                     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
                    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
                                     GET    /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 PATCH  /refinery/resources/:id(.:format)           refinery/admin/resources#update
                                     PUT    /refinery/resources/:id(.:format)           refinery/admin/resources#update
                                     DELETE /refinery/resources/:id(.:format)           refinery/admin/resources#destroy
                                     GET    /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 PATCH  /refinery/images/:id(.:format)              refinery/admin/images#update
                                     PUT    /refinery/images/:id(.:format)              refinery/admin/images#update
                                     DELETE /refinery/images/:id(.:format)              refinery/admin/images#destroy
                               login GET    /refinery/login(.:format)                   refinery/sessions#new
                              logout GET    /refinery/logout(.:format)                  refinery/sessions#destroy
                          new_signup GET    /refinery/users/register(.:format)          refinery/users#new
                              signup POST   /refinery/users/register(.:format)          refinery/users#create
           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
                                     PATCH  /refinery/users/password(.:format)          refinery/passwords#update
                                     PUT    /refinery/users/password(.:format)          refinery/passwords#update
                         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 PATCH  /refinery/users/:id(.:format)               refinery/admin/users#update
                                     PUT    /refinery/users/:id(.:format)               refinery/admin/users#update
                                     DELETE /refinery/users/:id(.:format)               refinery/admin/users#destroy
                             message GET    /refinery/message(.:format)                 refinery/fast#message
                          admin_root GET    /refinery(.:format)                         refinery/admin/core#index
                       admin_dialogs GET    /refinery/dialogs(.:format)                 refinery/admin/dialogs#index
                        admin_dialog GET    /refinery/dialogs/:id(.:format)             refinery/admin/dialogs#show
      refinery_update_menu_positions POST   /refinery/update_menu_positions(.:format)   refinery/admin/core#update_plugin_positions
                                     GET    /sitemap.xml(.:format)                      refinery/sitemap#index {:format=>"xml"}
                                     GET    /refinery/*path(.:format)                   refinery/admin#error_404
                     marketable_page GET    /*path(.:format)                            refinery/pages#show

尝试更改

<% unless current_page?(new_user_registration_path) %>

<% unless current_page?(main_app.new_user_registration_path) %>