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 CHANGED
@@ -36,17 +36,33 @@ rake db:roles:test
36
36
  >> Administrator, Moderator of pages, User, Demo
37
37
  ```
38
38
 
39
- Define alias method for **the_login_required** for correctly work of admin's controllers
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
- # TheRole login_required method alias
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
- before_filter :find_role, :only=>[:destroy, :delete_policy]
5
- before_filter :the_owner_require, :only=>[:destroy, :delete_policy]
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 find_role
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
- before_filter :find_role, :only => [:show, :edit, :update, :destroy, :new_role_section, :new_role_policy]
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 find_role
105
+ def the_role_find
104
106
  @role = Role.find(params[:id])
105
107
  end
106
108
 
@@ -8,7 +8,7 @@
8
8
  %p= link_to raw(t('.back')), admin_roles_path
9
9
 
10
10
  %h2
11
- = t('.name')
11
+ = raw t('.name')
12
12
  = @role.title
13
13
 
14
14
  = form_for :role, :url => {:action=> :update }, :html => {:method => :put, :class => :form } do |f|
@@ -4,7 +4,7 @@
4
4
  %p= m
5
5
 
6
6
  .form
7
- %h5= t('.create')
7
+ %h5= raw t('.create')
8
8
  = form_for(@role, :url => admin_roles_path) do |f|
9
9
  %label= t('.name')
10
10
  %p= f.text_field :name
@@ -1,3 +1,3 @@
1
1
  module TheRole
2
- VERSION = "1.3.1"
2
+ VERSION = "1.4.0"
3
3
  end
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 = "@" + self.class.to_s.underscore.split('_').first.singularize
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.3.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: &70239330 !ruby/object:Gem::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: *70239330
24
+ version_requirements: *77091770
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: sass
27
- requirement: &70239120 !ruby/object:Gem::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: *70239120
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