[英]Questions on routing in Rails 3 with Devise
I have a few related questions. 我有几个相关的问题。 I am new to Rails 3 after taking a year-long break from Rails in general.
在从Rails休息了一年之后,我对Rails 3还是陌生的。
I am using Devise for authentication and I have a controller and model called 'User'. 我正在使用Devise进行身份验证,并且有一个名为“用户”的控制器和模型。
So, I can use 'localhost:3000/users/sign_out' to log the user out. 因此,我可以使用“ localhost:3000 / users / sign_out”将用户注销。 I want to put a link at the top right that says 'logout' so when they click on it they get sent to 'users/sign_out'
我想在右上角添加一个“注销”链接,以便当他们单击它时将其发送到“用户/ sign_out”
How do I make a route for this so that I can say: 我如何为此做一个路线,这样我可以说:
<%= link_to "Logout", logout_path %>
Also, I want to refer to registered users as members. 另外,我想将注册用户称为成员。 Can I create a route to cloak this so that 'localhost/members' gets mapped to the 'users' controller?
我可以创建一条路线来掩饰此问题,以便将“ localhost / members”映射到“ users”控制器吗? Further, so that '/members/1/edit' is mapped to 'users/1/edit'?
此外,以便将“ / members / 1 / edit”映射到“ users / 1 / edit”吗?
Thanks in advance. 提前致谢。
关于您的第一个问题-我相信Wiki中有一个示例: http : //github.com/plataformatec/devise/wiki/操作方法 : -Change-the-default-sign_in-and-sign_out-routes
resources :members, :as => 'users'
第二个问题:现在您可以访问localhost / members,但实际上它处理的是UsersController。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.