开发者

Questions on routing in Rails 3 with Devise

开发者 https://www.devze.com 2023-01-22 14:29 出处:网络
I have a few related questions. I am new to Rails 3 after taking a year-long break from Rails in general.

I have a few related questions. I am new to Rails 3 after taking a year-long break from Rails in general.

I am using Devise for authentication and I have a controller and model called 'User'.

So, I can use 'localhost:3000/users/sign_out' to log the user 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'

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? Further, so that '/members/1/edit' is mapped to 'users/1/edit'?

Thanks in advance.


Regarding your first question - I believe that there is an example in wiki: http://github.com/plataformatec/devise/wiki/How-To:-Change-the-default-sign_in-and-sign_out-routes


resources :members, :as => 'users'

the second question: now you can visit localhost/members, but actually it deal with UsersController.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号