restful_authentication
关键字: rails restful authentication
restful_authentication是Rails的一个认证插件,基于REST方式,适合RESTful的geek
安装:
可选择性的修改routes:
一些helper方法:
安装:
- ruby script/plugin install http://svn.techno-weenie.net/projects/plugins/restful_authentication/
- ruby script/generate authenticated users sessions
- # routes.rb
- ActionController::Routing::Routes.draw do |map|
- map.home '', :controller => 'home', :action => 'index'
- map.resources :users
- map.resource :session
- map.signup '/signup', :controller => 'users', :action => 'new'
- map.login '/login', :controller => 'session', :action => 'new'
- map.logout '/logout', :controller => 'session', :action => 'destroy'
- end
- <!-- home/index.rhtml -->
- <h1>Welcome</h1>
- <% if logged_in? %>
- <p><strong>You are logged in as <%=h current_user.login %></strong></p>
- <p><%= link_to 'Logout', logout_path %></p>
- <% else %>
- <p><strong>You are currently not logged in.</strong></p>
- <p>
- <%= link_to 'Login', login_path %> or
- <%= link_to 'Sign Up', signup_path %>
- </p>
- <% end %>
莫愁前路无知己,天下无人不识君。