[英]Rails 3 devise user registration edit path not working
I have a pretty straight forward app with a couple tweaks to Devise. 我有一个非常直接的应用程序与Devise的几个调整。
First I created a Registrations controller that class RegistrationsController < Devise::RegistrationsController
inherits from Devise. 首先,我创建了一个Registers控制器,
class RegistrationsController < Devise::RegistrationsController
继承自Devise。 I created this controller so that I could edit users without re-supplying passwords. 我创建了这个控制器,以便我可以编辑用户而无需重新提供密码。 https://gist.github.com/1514687
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
它吐出的URL是(在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) (其他控制器操作类似,只需参考@user,不要担心这恰好称为帐户控制器)
In your routes.rb file make sure that you have 在你的routes.rb文件中确保你有
resources :users
after your devise_for line like below: 在您的devise_for行之后如下:
devise_for :users, :controllers => { :registrations => "registrations" }
resources :users
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.