Ruby on Rails - Devise注册链接不工作 - 未定义的方法`user_registration_path' [英] Ruby on Rails - Devise sign up link not working - undefined method `user_registration_path'

查看:160
本文介绍了Ruby on Rails - Devise注册链接不工作 - 未定义的方法`user_registration_path'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以前已经报告了此问题,但我仍然无法找到修复程序。

This issue has been previously reported, but I still have not been able to find a fix for it.

我已将插件Devise安装到我的新RoR项目中。当我点击注册链接时,我被重定向到以下路由:

I have installed the plugin Devise on to my new RoR project. When I click on the sign up link, I am redirected to the following route:

http:// localhost:3000 / users / registration / sign_up

但是,我得到以下错误:

However, I obtain the following error:

undefined method `user_registration_path' for #<#<Class:0x007fd5d3503d58>:0x007fd5d3b0dcd0>

提取源(绕行#5):

2:   <h1>Sign up</h1>
3: </div>
4: 
5: <%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
6:   <%= f.error_notification %>
7: 
8:   <div class="inputs">

我的路线产生以下内容:

My routes produces the following:

    new_user_session GET    /users/sign_in(.:format)              devise/sessions#new
        user_session POST   /users/sign_in(.:format)              devise/sessions#create
destroy_user_session GET    /users/sign_out(.:format)             devise/sessions#destroy
            password POST   /users/password(.:format)             devise/passwords#create {:name_prefix=>:user}
        new_password GET    /users/password/new(.:format)         devise/passwords#new {:name_prefix=>:user}
       edit_password GET    /users/password/edit(.:format)        devise/passwords#edit {:name_prefix=>:user}
                     PUT    /users/password(.:format)             devise/passwords#update {:name_prefix=>:user}
                     POST   /users/registration(.:format)         devise/registrations#create {:name_prefix=>"user_registration"}
                 new GET    /users/registration/sign_up(.:format) devise/registrations#new {:name_prefix=>"user_registration"}
                edit GET    /users/registration/edit(.:format)    devise/registrations#edit {:name_prefix=>"user_registration"}
                     PUT    /users/registration(.:format)         devise/registrations#update {:name_prefix=>"user_registration"}
                     DELETE /users/registration(.:format)         devise/registrations#destroy {:name_prefix=>"user_registration"}
          home_index GET    /home/index(.:format)                 home#index
               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
                root        /                                     home#index

我的routes.rb有以下代码:

My routes.rb has the following code:

 devise_for :users

  get "home/index"

  resources :users
  root :to => "home#index"


推荐答案

devise版本是1.1.0 RC,你正在运行Rails 3.

This problem is created when the devise version is 1.1.0 RC and you are running Rails 3.

请查看如何升级你的设计宝石:

Please look on how to upgrade your devise gem:

https://github.com/ plataformatec / devise / wiki / How-To:-Upgrade-to-Devise-2.0

希望这有帮助!

这篇关于Ruby on Rails - Devise注册链接不工作 - 未定义的方法`user_registration_path'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆