Created
July 27, 2013 16:24
-
-
Save grindars/6095344 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SlashAdmin.register model do | |
# Creates a controller for specified model. | |
# Returns new controller. | |
# Preferred form in autoloading environments is | |
# AdminFooController = SlashAdmin.register Foo | |
# | |
# Verbose form is also available: | |
# class AdminFooController < SlashAdmin::Controller | |
# admin Foo | |
index &block | |
# Specity alternative index table body. | |
# | |
# block (without arguments) - arbre template. | |
# | |
# /admin/index/default_index partial will be used if block was not specified. | |
# | |
# Example: | |
# index do | |
# header! do | |
# column I18n.t('admin.index.batch_select_column') | |
# column 'Foo' | |
# column I18n.t('admin.index.actions_column') | |
# end | |
# selectable_column | |
# column :foo | |
# default_actions | |
# end | |
show &block | |
# Specify alternative show page content. | |
# | |
# block (without arguments) - arbre template. | |
# | |
# /admin/show/default_show partial will be used if block was not specified. | |
# | |
# Example: | |
# show do | |
# attributes_table(foo) do | |
# row :id | |
# row :bar | |
# end | |
# end | |
form &block | |
# Specify alternative form fields. | |
# | |
# block (with form builder) - arbre template. | |
# | |
# /admin/default_form partial will be used if block was not specified. | |
# | |
# Example: | |
# form do |f| | |
# f.input :foo | |
# f.submit | |
# end | |
# Evaluated on each request | |
routing do | |
default_actions opts = {} | |
# Passes specified options to 'resources' method in routes. | |
member_action name, opts = {}, &block | |
collection_action name, opts = {}, &block | |
# Defines an action. | |
# name - action name (symbol) | |
# opts - passed to 'member' or 'collection' method in routes. | |
# block - action body. | |
# | |
# For member_action only, requested object is available as @object or controller.object. | |
# | |
# /admin/(pluralized resource name)/(action name) template will be used if block was not specified. | |
# | |
# Example: | |
# member_action :test, :method => :get | |
# | |
# Application-defined actions will override any DSL actions. | |
# For example, | |
# member_action :test do | |
# render :text => 'dsl' | |
# end | |
# def test | |
# render :text => 'plain' | |
# end | |
# will output 'plain' when called. | |
batch_actions(enabled = true) | |
# Enables or disables batch actions. | |
# Batch actions are enabled by default. | |
end | |
# Evaluated on each request | |
layout do | |
menu opts = {} | |
# Configures a menu item of this controller. | |
# | |
# Keys: | |
# hidden: if true, no menu item will be generated | |
# if: (Proc) menu item will be output only if lambda returns true. | |
# Called in the view context. | |
# label: used instead of default menu label. | |
# parent: nest item under item with this label. | |
# priority: sorting order. 10 by default | |
scope label, name, opts = {} | |
# Scopes are not currently implemented. | |
filter attribute, opts = {} | |
# Adds filter. | |
# No filters are used by default | |
# | |
# opts are not currently used. | |
action_item opts = {}, &block | |
# Adds action item. | |
# opts: | |
# except: if specified, hides item for specified actions (symbol or array) | |
# only: if specified, renders item for specified actions (symbol or array) | |
# block: arbre template | |
end | |
permit_params *params | |
# Calls permit! for specified parameters on params. Permits all parameters if | |
# called without any arguments. Does nothing if strong parameters are unavailable. | |
end | |
SlashAdmin.configure do |config| | |
config.admin_controller_paths = [ "app/controller/admin" ] | |
config.admin_modules = # implementation defined | |
config.authentication_method = :athenticate_admin_user! | |
config.current_user_method = :current_admin_user | |
config.brand = "SlashAdmin" | |
conifg.brand_url = { :controller => "dashboard", :action => "index" } | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment