cancan_namespace 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,17 +34,35 @@ Namespace for cancan gem.
34
34
  end
35
35
  end
36
36
 
37
+ In this case context extracted from controller name (:manage):
38
+
37
39
  class Manage::PostsController < Manage::BaseController
38
40
  before_filter :find_post, :only => [:edit, :update, :destroy]
39
41
  authorize_resource
40
42
  ...
41
43
  end
42
-
44
+
45
+ Set context for controller directly:
46
+
47
+ class People::RelationshipsController < Account::BaseController
48
+ before_filter :find_followed
49
+ before_filter :build_relation, :only => [:create]
50
+ before_filter :find_relationship, :only => [:destroy]
51
+
52
+ authorize_resource :relationship, :context => :account
53
+
54
+ ...
55
+
56
+ end
57
+
43
58
  === View
44
59
 
45
- <% if can? :edit, post, :context => :manage %>
46
- <%= link_to 'Edit', edit_manage_post_path(post) %>
60
+ <% if can? :edit, post %>
61
+ <%= link_to 'Edit', edit_post_path(post) %>
47
62
  <% end %>
48
63
 
64
+ <% if can? :edit, post, :context => :manage %>
65
+ <%= link_to 'Edit (admin)', edit_manage_post_path(post) %>
66
+ <% end %>
49
67
 
50
68
  Copyright (c) 2011 Aimbulance, released under the MIT license
@@ -18,7 +18,7 @@ module CanCanNamespace
18
18
  module InstanceMethods
19
19
  def authorize_resource_with_context
20
20
  unless skip?(:authorize)
21
- options = { :context => module_from_controller }
21
+ options = { :context => (@options[:context] || module_from_controller) }
22
22
  @controller.authorize!(authorization_action, resource_instance || resource_class_with_parent, options)
23
23
  end
24
24
  end
@@ -3,7 +3,7 @@ module CancanNamespace
3
3
  module Version
4
4
  MAJOR = 0
5
5
  MINOR = 1
6
- RELEASE = 2
6
+ RELEASE = 3
7
7
 
8
8
  def self.dup
9
9
  "#{MAJOR}.#{MINOR}.#{RELEASE}"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cancan_namespace
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Igor Galeta
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-04-09 00:00:00 +03:00
19
+ date: 2011-06-21 00:00:00 +03:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency