Rails 3设计用户注册编辑路径不工作 [英] Rails 3 devise user registration edit path not working

查看:182
本文介绍了Rails 3设计用户注册编辑路径不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



首先我创建了一个注册控制器,这个控制器是 class RegistrationsController< Devise :: RegistrationsController 继承自Devise。我创建了这个控制器,以便我可以在不重新提供密码的情况下编辑用户。 https://gist.github.com/1514687



我也在我的路线上做了这个:

  devise_for:users,:controllers => {:registrations => 注册}`

注册工作正常,但调用以下内容时:

 < p class =edit><%= link_to编辑,edit_user_registration_path(用户)%>< / p> 

它吐出的url是(在localhost上运行): http:/ /localhost:3000/users/edit.2



任何想法在这里?

解决方案

我推荐一个非设计控制器来做这个,并将其命名为用户,以避免与设计路线重叠



一些主要命名:

  rails g控制器帐户
资源:帐户

def edit
@user = User.find(params [:id]
end

(其他控制器操作类似,只是参考@user而不用担心这恰好称为帐户控制器)


I have a pretty straight forward app with a couple tweaks to Devise.

First I created a Registrations controller that class RegistrationsController < Devise::RegistrationsController inherits from Devise. I created this controller so that I could edit users without re-supplying passwords. https://gist.github.com/1514687

I also did this in my routes:

devise_for :users, :controllers => { :registrations => "registrations" }`

The signup works fine but when I call the following:

<p class="edit"><%= link_to "Edit", edit_user_registration_path(user) %></p>

The url it spits out is (running on localhost): http://localhost:3000/users/edit.2

Any ideas here?

解决方案

I recommend a non-devise controller for doing this, and name it something other that "users" for the sake of not overlapping with devise routes

some key nomenclature:

rails g controller accounts
resources :accounts

def edit
 @user = User.find(params[:id]
end

(other controller actions similar, just refer to @user and don't worry about that this happens to be called the accounts controller)

这篇关于Rails 3设计用户注册编辑路径不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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