the_role 1.3.1 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +18 -2
- data/app/controllers/admin/role_section_controller.rb +5 -3
- data/app/controllers/admin/roles_controller.rb +4 -2
- data/app/views/admin/roles/edit.html.haml +1 -1
- data/app/views/admin/roles/new.html.haml +1 -1
- data/lib/the_role/version.rb +1 -1
- data/lib/the_role.rb +1 -1
- metadata +5 -5
data/README.md
CHANGED
@@ -36,17 +36,33 @@ rake db:roles:test
|
|
36
36
|
>> Administrator, Moderator of pages, User, Demo
|
37
37
|
```
|
38
38
|
|
39
|
-
Define
|
39
|
+
Define aliases method for correctly work TheRole's controllers
|
40
40
|
|
41
41
|
**login_required** or any other method from your auth system
|
42
42
|
|
43
|
+
**access_denied** or any other method for processing access denied situation
|
44
|
+
|
43
45
|
``` ruby
|
44
46
|
class ApplicationController < ActionController::Base
|
45
47
|
# You Auth system
|
46
48
|
include AuthenticatedSystem
|
47
49
|
|
48
|
-
#
|
50
|
+
# define aliases for correctly work of TheRole gem
|
49
51
|
alias_method :the_login_required, :login_required
|
52
|
+
alias_method :the_role_access_denied, :access_denied
|
53
|
+
end
|
54
|
+
```
|
55
|
+
|
56
|
+
## Using with controllers
|
57
|
+
|
58
|
+
``` ruby
|
59
|
+
class ArticlesController < ApplicationController
|
60
|
+
before_filter :login_required
|
61
|
+
|
62
|
+
before_filter :the_role_require
|
63
|
+
before_filter :the_role_object, :only => [:new, :edit, :update, :destroy]
|
64
|
+
before_filter :the_owner_require, :only => [:new, :edit, :update, :destroy]
|
65
|
+
|
50
66
|
end
|
51
67
|
```
|
52
68
|
|
@@ -1,8 +1,10 @@
|
|
1
1
|
class Admin::RoleSectionController < ApplicationController
|
2
2
|
before_filter :login_required
|
3
3
|
before_filter :the_role_require
|
4
|
-
|
5
|
-
before_filter :
|
4
|
+
|
5
|
+
before_filter :the_role_find, :only => [:destroy, :delete_policy]
|
6
|
+
before_filter :the_role_object, :only => [:destroy, :delete_policy]
|
7
|
+
before_filter :the_owner_require, :only => [:destroy, :delete_policy]
|
6
8
|
|
7
9
|
def destroy
|
8
10
|
section_name = params[:id]
|
@@ -33,7 +35,7 @@ class Admin::RoleSectionController < ApplicationController
|
|
33
35
|
|
34
36
|
protected
|
35
37
|
|
36
|
-
def
|
38
|
+
def the_role_find
|
37
39
|
@role = Role.find(params[:role_id])
|
38
40
|
end
|
39
41
|
end
|
@@ -4,7 +4,9 @@ class Admin::RolesController < ApplicationController
|
|
4
4
|
layout 'the_role'
|
5
5
|
before_filter :the_login_required
|
6
6
|
before_filter :the_role_require
|
7
|
-
|
7
|
+
|
8
|
+
before_filter :the_role_find, :only => [:show, :edit, :update, :destroy, :new_role_section, :new_role_policy]
|
9
|
+
before_filter :the_role_object, :only => [:show, :edit, :update, :destroy, :new_role_section, :new_role_policy]
|
8
10
|
before_filter :the_owner_require, :only => [:show, :edit, :update, :destroy, :new_role_section, :new_role_policy]
|
9
11
|
|
10
12
|
def index
|
@@ -100,7 +102,7 @@ class Admin::RolesController < ApplicationController
|
|
100
102
|
|
101
103
|
protected
|
102
104
|
|
103
|
-
def
|
105
|
+
def the_role_find
|
104
106
|
@role = Role.find(params[:id])
|
105
107
|
end
|
106
108
|
|
data/lib/the_role/version.rb
CHANGED
data/lib/the_role.rb
CHANGED
@@ -104,7 +104,7 @@ module TheRole
|
|
104
104
|
# define class variable for *the_owner_require* filter with Controller class name
|
105
105
|
# @the_role_object = @article
|
106
106
|
def the_role_object
|
107
|
-
variable_name =
|
107
|
+
variable_name = self.to_s.tableize.split('_').first.singularize.split('/').last
|
108
108
|
@the_role_object = self.instance_variable_get("@#{variable_name}")
|
109
109
|
end
|
110
110
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: the_role
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-11-12 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: haml
|
16
|
-
requirement: &
|
16
|
+
requirement: &77091770 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '3.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *77091770
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: sass
|
27
|
-
requirement: &
|
27
|
+
requirement: &77091560 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *77091560
|
36
36
|
description: TheRole - simple, but powerful role system for ROR applications
|
37
37
|
email:
|
38
38
|
- zykin-ilya@ya.ru
|