Permalink
Browse files

fix a bug where the new action would hide other actions tabs because …

…the new objects doesn't satisfy authorizations constraints
  • Loading branch information...
1 parent 259ed4c commit 4616200f79ce587fd144257b663f0cda6307c31e @bbenezech bbenezech committed Dec 4, 2012
@@ -5,8 +5,9 @@ module ApplicationHelper
include RailsAdmin::I18nSupport
- def authorized?(*args)
- @authorization_adapter.nil? || @authorization_adapter.authorized?(*args)
+ def authorized?(action, abstract_model = nil, object = nil)
+ object = nil if object.try :new_record?
+ @authorization_adapter.nil? || @authorization_adapter.authorized?(action, abstract_model, object)
end
def current_action?(action, abstract_model = @abstract_model, object = @object)
@@ -30,7 +30,8 @@ class Base
register_instance_option :authorized? do
(
- bindings[:controller].nil? or bindings[:controller].authorized?(self.authorization_key, bindings[:abstract_model], bindings[:object])) and (
+ bindings[:controller].nil? or bindings[:controller].authorized?(self.authorization_key, bindings[:abstract_model], bindings[:object])
+ ) and (
bindings[:abstract_model].nil? or (
(only.nil? or [only].flatten.map(&:to_s).include?(bindings[:abstract_model].to_s)) and
![except].flatten.map(&:to_s).include?(bindings[:abstract_model].to_s) and
Oops, something went wrong.

0 comments on commit 4616200

Please sign in to comment.