1010require 'active_admin/resource_controller/scoping'
1111
1212module ActiveAdmin
13- class ResourceController < ::InheritedResources ::Base
14-
15- helper ::ActiveAdmin ::ViewHelpers
16-
13+ class ResourceController < BaseController
1714 layout :determine_active_admin_layout
1815
1916 respond_to :html , :xml , :json
2017 respond_to :csv , :only => :index
2118
22- before_filter :only_render_implemented_actions
23- before_filter :authenticate_active_admin_user
24-
2519 ACTIVE_ADMIN_ACTIONS = [ :index , :show , :new , :create , :edit , :update , :destroy ]
2620
2721 include Actions
@@ -35,13 +29,6 @@ class ResourceController < ::InheritedResources::Base
3529 include Scoping
3630
3731 class << self
38- # Ensure that this method is available for the DSL
39- public :actions
40-
41- # Reference to the Resource object which initialized
42- # this controller
43- attr_accessor :active_admin_config
44-
4532 def active_admin_config = ( config )
4633 @active_admin_config = config
4734 defaults :resource_class => config . resource ,
@@ -52,14 +39,7 @@ def active_admin_config=(config)
5239 public :belongs_to
5340 end
5441
55- protected
56-
57- # By default Rails will render un-implemented actions when the view exists. Becuase Active
58- # Admin allows you to not render any of the actions by using the #actions method, we need
59- # to check if they are implemented.
60- def only_render_implemented_actions
61- raise AbstractController ::ActionNotFound unless action_methods . include? ( params [ :action ] )
62- end
42+ private
6343
6444 # Determine which layout to use.
6545 #
@@ -72,39 +52,11 @@ def determine_active_admin_layout
7252 ACTIVE_ADMIN_ACTIONS . include? ( params [ :action ] . to_sym ) ? false : 'active_admin'
7353 end
7454
75- # Calls the authentication method as defined in ActiveAdmin.authentication_method
76- def authenticate_active_admin_user
77- send ( active_admin_namespace . authentication_method ) if active_admin_namespace . authentication_method
78- end
79-
80- def current_active_admin_user
81- send ( active_admin_namespace . current_user_method ) if active_admin_namespace . current_user_method
82- end
83- helper_method :current_active_admin_user
84-
85- def current_active_admin_user?
86- !current_active_admin_user . nil?
87- end
88- helper_method :current_active_admin_user?
89-
90- def active_admin_config
91- self . class . active_admin_config
92- end
93- helper_method :active_admin_config
94-
95- def active_admin_namespace
96- active_admin_config . namespace
97- end
98- helper_method :active_admin_namespace
99-
100- def active_admin_namespace
101- active_admin_config . namespace
102- end
103-
10455 # Returns the renderer class to use for the given action.
10556 def renderer_for ( action )
10657 active_admin_namespace . view_factory [ "#{ action } _page" ]
10758 end
10859 helper_method :renderer_for
60+
10961 end
11062end
0 commit comments