class ActiveAdmin::ResourceController

def active_admin_application

def active_admin_application
  ActiveAdmin.application
end

def active_admin_config

def active_admin_config
  self.class.active_admin_config
end

def active_admin_config=(config)

def active_admin_config=(config)
  @active_admin_config = config
  defaults  :resource_class => config.resource,
            :route_prefix => config.route_prefix,
            :instance_name => config.underscored_resource_name
end

def active_admin_template(template)

Returns the full location to the Active Admin template path
def active_admin_template(template)
  "active_admin/resource/#{template}"
end

def authenticate_active_admin_user

Calls the authentication method as defined in ActiveAdmin.authentication_method
def authenticate_active_admin_user
  send(active_admin_application.authentication_method) if active_admin_application.authentication_method
end

def create(options={}, &block)

def create(options={}, &block)
  super(options) do |success, failure|
    block.call(success, failure) if block
    failure.html { render active_admin_template('new.html.arb') }
  end
end

def csv_filename

and current date such as 'my-articles-2011-06-24.csv'.
Returns a filename for the csv file using the collection_name
def csv_filename
  "#{resource_collection_name.to_s.gsub('_', '-')}-#{Time.now.strftime("%Y-%m-%d")}.csv"
end

def current_active_admin_user

def current_active_admin_user
  send(active_admin_application.current_user_method) if active_admin_application.current_user_method
end

def current_active_admin_user?

def current_active_admin_user?
  !current_active_admin_user.nil?
end

def determine_active_admin_layout

that users can render any template inside Active Admin.
2. If we're rendering a custom action, we'll use the active_admin layout so
all the required layout code)
because these actions are subclasses of the Base page (which implementes
1. If we're rendering a standard Active Admin action, we want layout(false)

Determine which layout to use.
def determine_active_admin_layout
  ACTIVE_ADMIN_ACTIONS.include?(params[:action].to_sym) ? false : 'active_admin'
end

def edit(options={}, &block)

def edit(options={}, &block)
  super do |format|
    block.call(format) if block
    format.html { render active_admin_template('edit.html.arb') }
  end
end

def index(options={}, &block)

def index(options={}, &block)
  super(options) do |format|
    block.call(format) if block
    format.html { render active_admin_template('index.html.arb') }
    format.csv do
      headers['Content-Type'] = 'text/csv; charset=utf-8'
      headers['Content-Disposition'] = %{attachment; filename="#{csv_filename}"}
      render active_admin_template('index.csv.erb')
    end
  end
end

def new(options={}, &block)

def new(options={}, &block)
  super do |format|
    block.call(format) if block
    format.html { render active_admin_template('new.html.arb') }
  end
end

def only_render_implemented_actions

to check if they are implemented.
Admin allows you to not render any of the actions by using the #actions method, we need
By default Rails will render un-implemented actions when the view exists. Becuase Active
def only_render_implemented_actions
  raise AbstractController::ActionNotFound unless action_methods.include?(params[:action])
end

def renderer_for(action)

Returns the renderer class to use for the given action.
def renderer_for(action)
  active_admin_application.view_factory["#{action}_page"]
end

def show(options={}, &block)

def show(options={}, &block)
  super do |format|
    block.call(format) if block
    format.html { render active_admin_template('show.html.arb') }
  end
end

def update(options={}, &block)

def update(options={}, &block)
  super do |success, failure|
    block.call(success, failure) if block
    failure.html { render active_admin_template('edit.html.arb') }
  end
end