Skip to content

Commit

Permalink
fix a bug where the new action would hide other actions tabs because …
Browse files Browse the repository at this point in the history
…the new objects doesn't satisfy authorizations constraints
  • Loading branch information
bbenezech committed Dec 4, 2012
1 parent 259ed4c commit 4616200
Show file tree
Hide file tree
Showing 3 changed files with 264 additions and 237 deletions.
5 changes: 3 additions & 2 deletions app/helpers/rails_admin/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion lib/rails_admin/config/actions/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 4616200

Please sign in to comment.