cancan 1.5.0.beta1 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +1 -1
- data/README.rdoc +13 -22
- metadata +4 -5
data/CHANGELOG.rdoc
CHANGED
data/README.rdoc
CHANGED
@@ -22,25 +22,15 @@ Alternatively, you can install it as a plugin.
|
|
22
22
|
|
23
23
|
== Getting Started
|
24
24
|
|
25
|
-
CanCan expects a +current_user+ method to exist in controllers.
|
25
|
+
CanCan expects a +current_user+ method to exist in controllers. First, set up some authentication (such as Authlogic[https://github.com/binarylogic/authlogic] or Devise[https://github.com/plataformatec/devise]). See {Changing Defaults}[https://github.com/ryanb/cancan/wiki/changing-defaults] if you need to customize this behavior.
|
26
26
|
|
27
|
-
Next
|
27
|
+
Next, make an +Ability+ class. CanCan 1.5 includes a generator for this.
|
28
28
|
|
29
|
-
|
30
|
-
include CanCan::Ability
|
29
|
+
rails g cancan:ability
|
31
30
|
|
32
|
-
|
33
|
-
if user.admin?
|
34
|
-
can :manage, :all
|
35
|
-
else
|
36
|
-
can :read, :all
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
The +current_user+ is passed in to this method which is where the abilities are defined. See {Defining Abilities}[https://github.com/ryanb/cancan/wiki/defining-abilities] for what can go here.
|
31
|
+
This is where the user permission will be defined. See the comments in models/ability.rb and {Defining Abilities}[https://github.com/ryanb/cancan/wiki/defining-abilities] for details.
|
42
32
|
|
43
|
-
The current user's permissions can then be
|
33
|
+
The current user's permissions can then be checked using the <tt>can?</tt> and <tt>cannot?</tt> methods in the view and controller.
|
44
34
|
|
45
35
|
<% if can? :update, @article %>
|
46
36
|
<%= link_to "Edit", edit_article_path(@article) %>
|
@@ -65,7 +55,7 @@ Setting this for every action can be tedious, therefore the +load_and_authorize_
|
|
65
55
|
end
|
66
56
|
end
|
67
57
|
|
68
|
-
See {Authorizing Controller Actions}[https://github.com/ryanb/cancan/wiki/authorizing-controller-actions] for more information
|
58
|
+
See {Authorizing Controller Actions}[https://github.com/ryanb/cancan/wiki/authorizing-controller-actions] for more information.
|
69
59
|
|
70
60
|
If the user authorization fails, a <tt>CanCan::AccessDenied</tt> exception will be raised. You can catch this and modify its behavior in the +ApplicationController+.
|
71
61
|
|
@@ -79,13 +69,14 @@ If the user authorization fails, a <tt>CanCan::AccessDenied</tt> exception will
|
|
79
69
|
See {Exception Handling}[https://github.com/ryanb/cancan/wiki/exception-handling] for more information.
|
80
70
|
|
81
71
|
|
82
|
-
==
|
72
|
+
== Wiki Docs
|
83
73
|
|
84
|
-
* {Upgrading to 1.
|
85
|
-
* {
|
86
|
-
* {
|
87
|
-
* {
|
88
|
-
* {
|
74
|
+
* {Upgrading to 1.5}[https://github.com/ryanb/cancan/wiki/Upgrading-to-1.5]
|
75
|
+
* {Defining Abilities}[https://github.com/ryanb/cancan/wiki/Defining-Abilities]
|
76
|
+
* {Checking Abilities}[https://github.com/ryanb/cancan/wiki/Checking-Abilities]
|
77
|
+
* {Authorizing Controller Actions}[https://github.com/ryanb/cancan/wiki/Authorizing-Controller-Actions]
|
78
|
+
* {Exception Handling}[https://github.com/ryanb/cancan/wiki/Exception-Handling]
|
79
|
+
* {Changing Defaults}[https://github.com/ryanb/cancan/wiki/Changing-Defaults]
|
89
80
|
* {See more}[https://github.com/ryanb/cancan/wiki]
|
90
81
|
|
91
82
|
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cancan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 3
|
5
|
+
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 5
|
9
9
|
- 0
|
10
|
-
|
11
|
-
version: 1.5.0.beta1
|
10
|
+
version: 1.5.0
|
12
11
|
platform: ruby
|
13
12
|
authors:
|
14
13
|
- Ryan Bates
|
@@ -16,7 +15,7 @@ autorequire:
|
|
16
15
|
bindir: bin
|
17
16
|
cert_chain: []
|
18
17
|
|
19
|
-
date: 2011-01-
|
18
|
+
date: 2011-01-11 00:00:00 -08:00
|
20
19
|
default_executable:
|
21
20
|
dependencies:
|
22
21
|
- !ruby/object:Gem::Dependency
|