3

我有一个问题,起初看起来并不难,但实际上我无法解决。我正在尝试将炼油厂用作应用程序的 CMS。我想将 Refinery 用户和其他类型的用户分开,称他们为 mktgeistusers,他们需要注册和登录才能访问某些受保护的页面。所以我首先创建了一个没有炼油厂的应用程序(只有设计),以确保一切正常(从身份验证方面)。这里没有问题。下一步是通过执行以下操作创建全新的炼油厂安装:

refinerycms testRefineryPlusDevise  -d mysql 


add other refinery gems to the Gemfile

gem 'refinerycms-i18n', '~> 2.0.0'
gem 'refinerycms-blog', '~> 2.0.0'
gem 'refinerycms-inquiries', '~> 2.0.0'
gem 'refinerycms-search', '~> 2.0.0', :git => 'git://github.com/refinery/refinerycms-search.git', :branch => '2-0-stable'
gem 'refinerycms-page-images', '~> 2.0.0'
gem "refinerycms-news", '~> 2.0.0'

bundle update

rails generate refinery:blog
rails generate refinery:inquiries
rails generate refinery:news

rake db:migrate

它创造了应有的一切。当我继续创建新类型的用户时,问题就开始了:

rails generate devise Mktgeistuser 

      invoke  active_record
      create    db/migrate/20121019201721_devise_create_mktgeistusers.rb
      create    app/models/mktgeistuser.rb
      invoke    test_unit
      create      test/unit/mktgeistuser_test.rb
      create      test/fixtures/mktgeistusers.yml
      insert    app/models/mktgeistuser.rb
       route  devise_for :mktgeistusers

rake db:migrate

用户现已创建。然后我添加了一个静态页面来放置登录/注销链接以进行测试,并添加了以下路由:

  #devise_for :mktgeistusers

  devise_for :mktgeistuser, :controllers=>{:sessions=>"mktgeistuser/sessions"} do
    match '/mktgeistuser/sign_out', :action=>"destroy", :controller=>"devise/sessions"
    match '/mktgeistuser/sign_in',  :action=>"new", :controller=>"devise/sessions"
    match '/mktgeistuser/sign_up',  :action=>"new", :controller=>"devise/registrations"
  end


  root :to => "static#home"



 default of "refinery"
      mount Refinery::Core::Engine, :at => '/refinery'

在 static/home 中有这样的:

<h1>Static#home</h1>
<p>
    Find me in app/views/static/home.html.erb
</p>
<div id="user_nav">
    <% if mktgeistuser_signed_in? %>
    Signed in as <%= current_mktgeistuser.email %>.
    <%= link_to "Sign out", destroy_mktgeistuser_session_path, :method => :delete %>
    <% else %>
    <%= link_to 'Register', new_mktgeistuser_registration_path %> or <%= link_to 'Sign in', new_mktgeistuser_session_path %>
    <% end %>
</div>
<%= javascript_include_tag :defaults %>

问题是,当炼油厂在玩时,应用程序找不到 mktgeist 用户的设计助手:当我点击登录/注册链接时,我得到

NoMethodError in Devise/sessions#new

Showing /home/mike/.rvm/gems/ruby-1.9.2-p290/gems/devise-2.0.4/app/views/devise/sessions/new.html.erb where line #3 raised:

undefined method `mktgeistuser_session_path' for #<ActionDispatch::Routing::RoutesProxy:0xdeb1d6c>
Extracted source (around line #3):

1: <h2>Sign in</h2>
2: 
3: 

<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
4:   <div><%= f.label :email %><br />
5:   <%= f.email_field :email %></div>
6: 

同样,找不到destroy_mktgeistuser_session_path new_mktgeistuser_registration_path 和new_mktgeistuser_session_path。你知道如何解决这个问题吗?

顺便说一句,这是一个 rake 路由输出

                         static_home GET    /static/home(.:format)                static#home
           mktgeistuser_sign_out        /mktgeistuser/sign_out(.:format)      devise/sessions#destroy
            mktgeistuser_sign_in        /mktgeistuser/sign_in(.:format)       devise/sessions#new
            mktgeistuser_sign_up        /mktgeistuser/sign_up(.:format)       devise/registrations#new
        new_mktgeistuser_session GET    /mktgeistuser/sign_in(.:format)       mktgeistuser/sessions#new
            mktgeistuser_session POST   /mktgeistuser/sign_in(.:format)       mktgeistuser/sessions#create
    destroy_mktgeistuser_session DELETE /mktgeistuser/sign_out(.:format)      mktgeistuser/sessions#destroy
           mktgeistuser_password POST   /mktgeistuser/password(.:format)      devise/passwords#create
       new_mktgeistuser_password GET    /mktgeistuser/password/new(.:format)  devise/passwords#new
      edit_mktgeistuser_password GET    /mktgeistuser/password/edit(.:format) devise/passwords#edit
                                 PUT    /mktgeistuser/password(.:format)      devise/passwords#update
cancel_mktgeistuser_registration GET    /mktgeistuser/cancel(.:format)        devise/registrations#cancel
       mktgeistuser_registration POST   /mktgeistuser(.:format)               devise/registrations#create
   new_mktgeistuser_registration GET    /mktgeistuser/sign_up(.:format)       devise/registrations#new
  edit_mktgeistuser_registration GET    /mktgeistuser/edit(.:format)          devise/registrations#edit
                                 PUT    /mktgeistuser(.:format)               devise/registrations#update
                                 DELETE /mktgeistuser(.:format)               devise/registrations#destroy
                            root        /                                     static#home
                        refinery        /                                     Refinery::Core::Engine

Routes for Refinery::Core::Engine:
                                                    /system/resources/*dragonfly(.:format)                    <Dragonfly::App name=:refinery_resource
s >
                     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_upgrad
e_message
                                                    /system/resources/*dragonfly(.:format)                    <Dragonfly::App name=:refinery_resource
s >
                                            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_upgrad
e_message
                                                    /system/resources/*dragonfly(.:format)                    <Dragonfly::App name=:refinery_resource
s >
                                            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_upgrad
e_message
                                  news_root         /news(.:format)                                           refinery/news/items#index
                         news_items_archive GET     /news/archive/:year(/:month)(.:format)                    refinery/news/items#archive
                                 news_items GET     /news(.:format)                                           refinery/news/items#index
                                  news_item GET     /news/:id(.:format)                                       refinery/news/items#show
                            news_admin_root         /refinery/news(.:format)                                  refinery/news/admin/items#index
                           news_admin_items GET     /refinery/news/items(.:format)                            refinery/news/admin/items#index
                                            POST    /refinery/news/items(.:format)                            refinery/news/admin/items#create
                        new_news_admin_item GET     /refinery/news/items/new(.:format)                        refinery/news/admin/items#new
                       edit_news_admin_item GET     /refinery/news/items/:id/edit(.:format)                   refinery/news/admin/items#edit
                            news_admin_item PUT     /refinery/news/items/:id(.:format)                        refinery/news/admin/items#update
                                            DELETE  /refinery/news/items/:id(.:format)                        refinery/news/admin/items#destroy
                                     search         /search(.:format)                                         refinery/search#show
                      inquiries_new_inquiry GET     /contact(.:format)                                        refinery/inquiries/inquiries#new
              thank_you_inquiries_inquiries GET     /contact/thank_you(.:format)                              refinery/inquiries/inquiries#thank_you
                        inquiries_inquiries POST    /contact(.:format)                                        refinery/inquiries/inquiries#create
             spam_inquiries_admin_inquiries GET     /refinery/inquiries/spam(.:format)                        refinery/inquiries/admin/inquiries#spam
        toggle_spam_inquiries_admin_inquiry GET     /refinery/inquiries/:id/toggle_spam(.:format)             refinery/inquiries/admin/inquiries#togg
le_spam
                  inquiries_admin_inquiries GET     /refinery/inquiries(.:format)                             refinery/inquiries/admin/inquiries#inde
x
                    inquiries_admin_inquiry GET     /refinery/inquiries/:id(.:format)                         refinery/inquiries/admin/inquiries#show
                                            DELETE  /refinery/inquiries/:id(.:format)                         refinery/inquiries/admin/inquiries#dest
roy
               edit_inquiries_admin_setting GET     /refinery/inquiries/settings/:id/edit(.:format)           refinery/inquiries/admin/settings#edit
                    inquiries_admin_setting PUT     /refinery/inquiries/settings/:id(.:format)                refinery/inquiries/admin/settings#updat
e
                                  blog_root         /blog(.:format)                                           refinery/blog/posts#index
                                  blog_post GET     /blog/posts/:id(.:format)                                 refinery/blog/posts#show
                              blog_rss_feed         /blog/feed.rss(.:format)                                  refinery/blog/posts#index {:format=>"rs
s"}
                              blog_category         /blog/categories/:id(.:format)                            refinery/blog/categories#show
                              blog_comments         /blog/:id/comments(.:format)                              

ETC

非常感谢您的任何帮助或建议!

顺便说一句,我正在使用设计 2.0.4

4

1 回答 1

0

你需要改变

<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) %>

<%= form_for(resource, :as => resource_name, :url => mktgeistuser_session_path) %>
于 2013-07-18T04:01:36.633 回答