Module: BootstrapAdmin::ControllerHelpers::ClassMethods

Defined in:
lib/bootstrap_admin/controller_helpers.rb

Overview

Instance Method Summary collapse

Instance Method Details

#bootstrap_admin(&block) ⇒ Object

Controller Macro to define and configure bootstrap_admin

When you run this macro on a controller, it:

* sets BootstrapAdmin::Responder as the controller's responder
* includes BootstrapAdmin::Actions, defining the controller's default actions
* adds helpers (bootstrap_admin, bootstrap_admin/paginator and bootstrap_admin/menu)
* adds the bootstrap_admin default views to the viewpath

Parameters

block

an optional code block that will receive an instance of BootstrapAdmin::ControllerConfig to configure controller specific stuff, such as index_fields, etc..



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/bootstrap_admin/controller_helpers.rb', line 16

def bootstrap_admin &block
  @bootstrap_admin_config = BootstrapAdmin::ControllerConfig.new # config
  if block_given?
    block.call @bootstrap_admin_config
  end

  self.respond_to *@bootstrap_admin_config.responder_formats
  self.responder = BootstrapAdmin::Responder
  # setup bootstrap_admin viewpath
  add_bootstrap_admin_viewpath

  # add bootstrap_admin helpers
  helper "bootstrap_admin"
  helper "bootstrap_admin/paginator"
  helper "bootstrap_admin/menu"

  layout "bootstrap_admin"

  # add bootstrap_admin actions
  self.send :include, BootstrapAdmin::Actions
  helper_method :bootstrap_admin_config
end