Commit a99e0f774a78f2c19bf0c7f38aba7d084765d6f9
1 parent
71c87dac
Exists in
master
and in
29 other branches
ActionItem117: renaming
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@909 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
23 additions
and
23 deletions
Show diff stats
... | ... | @@ -0,0 +1,23 @@ |
1 | +class MyProfileController < ApplicationController | |
2 | + | |
3 | + needs_profile | |
4 | + | |
5 | + # declares that the controller needs an specific type of profile. Example: | |
6 | + # | |
7 | + # class PersonDetailControlles < ProfileAdminController | |
8 | + # requires_profile_class Person | |
9 | + # end | |
10 | + # | |
11 | + # The above controller will reject every request to it unless the current | |
12 | + # profile (as indicated by the first URL component) is of class Person (or of | |
13 | + # a subclass of Person) | |
14 | + def self.requires_profile_class(some_class) | |
15 | + before_filter do |controller| | |
16 | + unless controller.send(:profile).kind_of?(some_class) | |
17 | + controller.instance_variable_set('@message', _("This action is not available for \"%s\".") % controller.send(:profile).name) | |
18 | + controller.render :file => File.join(RAILS_ROOT, 'app', 'views', 'shared', 'access_denied.rhtml'), :layout => true, :status => 403 | |
19 | + end | |
20 | + end | |
21 | + end | |
22 | + | |
23 | +end | ... | ... |
app/controllers/profile_admin_controller.rb
... | ... | @@ -1,23 +0,0 @@ |
1 | -class MyProfileController < ApplicationController | |
2 | - | |
3 | - needs_profile | |
4 | - | |
5 | - # declares that the controller needs an specific type of profile. Example: | |
6 | - # | |
7 | - # class PersonDetailControlles < ProfileAdminController | |
8 | - # requires_profile_class Person | |
9 | - # end | |
10 | - # | |
11 | - # The above controller will reject every request to it unless the current | |
12 | - # profile (as indicated by the first URL component) is of class Person (or of | |
13 | - # a subclass of Person) | |
14 | - def self.requires_profile_class(some_class) | |
15 | - before_filter do |controller| | |
16 | - unless controller.send(:profile).kind_of?(some_class) | |
17 | - controller.instance_variable_set('@message', _("This action is not available for \"%s\".") % controller.send(:profile).name) | |
18 | - controller.render :file => File.join(RAILS_ROOT, 'app', 'views', 'shared', 'access_denied.rhtml'), :layout => true, :status => 403 | |
19 | - end | |
20 | - end | |
21 | - end | |
22 | - | |
23 | -end |