public
Description: cheat sheet repository for chit
Homepage:
Clone URL: git://github.com/robin/chitsheet.git
robin (author)
Wed Jul 09 03:11:05 -0700 2008
commit  4d546432dd5b473dbbb5883f19cacc71b4599483
tree    d2371207000e34eb8ae02337f9e5c2f03ffdd22d
parent  8b2c5772e458466c24b4c2360fcf24e8b3b72468
chitsheet / acts_as_authenticated.yml
100644 25 lines (24 sloc) 1.511 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
---
acts_as_authenticated: "See: http://technoweenie.stikipad.com/plugins/show/User+Authentication\r\n\
  \r\n\
  Install:\r\n\
  >> ruby script/plugin source http://svn.techno-weenie.net/projects/plugins\r\n\
  >> ruby script/plugin install acts_as_authenticated\r\n\
  \r\n\
  Generate:\r\n\
  >> ruby script/generate authenticated user account\r\n\
  >> rake db:migrate\r\n\
  \r\n\
  To require logins for all actions, use this in your controllers:\r\n before_filter :login_required\r\n\
  \r\n\
  To require logins for specific actions, use this in your controllers:\r\n before_filter :login_required, :only => [ :edit, :update ]\r\n\
  \r\n\
  To skip this in a subclassed controller:\r\n skip_before_filter :login_required\r\n\
  \r\n\
  Here are other available methods for your views and controllers:\r\n * logged_in? \xE2\x80\x93 Returns true if the user is currently logged in.\r\n * current_user \xE2\x80\x93 Returns an instance of the currently logged in user.\r\n\
  \r\n\
  You can override the #protect? method in your controller to only protect certain actions:\r\n\
  \r\n # don't protect the login and the about method\r\n def protect?(action)\r\n if ['login', 'about'].include?(action)\r\n return false\r\n else\r\n return true\r\n end\r\n end\r\n\
  \r\n\
  You can also override #authorized? in your controller to restrict the actions based on the user:\r\n\
  \r\n # only allow nonbobs\r\n def authorized?(user)\r\n user.login != \"bob\" \r\n end"