2013-05-03 22 views
1

我想将Devise模型添加到RefineryCMS应用程序以允许客户登录并管理其配置文件。这样做似乎是合理的,因为客户与CMS无关。由于RefineryCMS使用Devise,我认为这将是一件简单的事情。我从一个空白的平板开始,而不是与现有的应用程序集成。将设计模型添加到RefineryCMS应用程序中的问题

步骤来重现我遇到的问题:

$ refinerycms my_fun_app 
$ cd my_fun_app 
$ rails generate devise customer 
$ rake db:migrate 

做的步骤后上面我火起来的应用程序(使用rails server)和去http://localhost:3000我得到提示创建一个炼油厂的用户。一切都很好。

问题是,当我去http://localhost:3000/customers/sign_up我得到一个NoMethodError

undefined method `customer_registration_path' for #<ActionDispatch::Routing::RoutesProxy:0x00000003cc9810> 

错误是从该行/home/tom/.rvm/gems/ruby-2.0.0-p0/提高宝石/设计-2.0.5 /应用/视图/设计/注册/ new.html.erb:

​​

如何解决这个问题的任何想法?

回答

0

尝试改变这行代码:

​​

<%= form_for(resource, :as => resource_name, :url => customer_registration_path(resource_name)) do |f| %> 
1

这是RefineryCMS一个已知的问题,因为它是基于设计和设置设计作为自己的路:

Devise.setup do |config| 
    # Please do not change the router_name away from :refinery 
    # otherwise Refinery may not function properly. Thanks! 
    config.router_name = :refinery 
end 

所以在Devise中,URL帮助程序找不到在您的应用程序中定义的那个。

这个问题似乎没有正式的解决方案,RefineryCMS的工作人员正在研究这个问题,因此它可能在未来的版本中得到修复。然而,关于如何将Refinery和Devise集成到现有的Rails 3.2应用程序中,有一篇很好的文章,可能会给你一些想法:http://sdownie.com/blogs/integrating-refinery-rails-3-2-into-your-existing-rails-app

希望这会有所帮助。

0

我通过将url更改为硬编码路径得到了这个工作。例如,如果你运行rake路线,并得到:

$ bundle exec rake routes | grep devise 
cancel_customer_registration GET /customers/cancel(.:format)  devise/registrations#cancel 
     customer_registration POST /customers(.:format)    devise/registrations#create 
    new_customer_registration GET /customers/sign_up(.:format)  devise/registrations#new 
    edit_customer_registration GET /customers/edit(.:format)   devise/registrations#edit 
          PUT /customers(.:format)    devise/registrations#update 
          DELETE /customers(.:format)    devise/registrations#destroy 

那么你会改变这行代码:

​​

<%= form_for(resource, :as => resource_name, :url => "/customers") do |f| %> 
相关问题