Module: ActionAdmin::AdminHelper

Defined in:
app/helpers/action_admin/admin_helper.rb

Instance Method Summary collapse

Instance Method Details

#admin_action_title(action = nil) ⇒ Object



7
8
9
10
11
12
# File 'app/helpers/action_admin/admin_helper.rb', line 7

def admin_action_title(action=nil)
  if controller.respond_to? :action_header
    name = action || action_name
    controller.action_header.action_title(name, self)
  end
end

#admin_app_nameObject



3
4
5
# File 'app/helpers/action_admin/admin_helper.rb', line 3

def admin_app_name
  ActionAdmin.config.app_name
end

#admin_meta_tagsObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/helpers/action_admin/admin_helper.rb', line 14

def admin_meta_tags
  tags = {
    site:     admin_app_name,
    noindex:  true,
    nofollow: true,
    reverse:  true,
    title:    admin_action_title || "#{action_name}".titleize,
    charset:  'utf-8',
    viewport: 'width=device-width, initial-scale=1.0'
  }

  set_meta_tags tags
  display_meta_tags
end

#admin_present(record, presenter = nil) ⇒ Object



29
30
31
32
33
34
35
36
# File 'app/helpers/action_admin/admin_helper.rb', line 29

def admin_present(record, presenter=nil)
  record     = record.new if record.respond_to? :new
  class_name = record.class.name
  presenter  = presenter || "Admin::#{class_name}Presenter"
  presenter  = "#{presenter}".safe_constantize || 'ActionAdmin::Presenter'.constantize

  presenter.new(record, self)
end

#admin_present_many(records, presenter = nil) ⇒ Object



38
39
40
# File 'app/helpers/action_admin/admin_helper.rb', line 38

def admin_present_many(records, presenter=nil)
  records.to_a.map { |r| admin_present(r, presenter) }
end

#admin_render_template(fallback) ⇒ Object



42
43
44
45
46
47
48
# File 'app/helpers/action_admin/admin_helper.rb', line 42

def admin_render_template(fallback)
  template = Hash(controller._action_templates[:"#{action_name}"])
  partial  = template.fetch :partial, fallback
  options  = template.except(:partial)

  render partial, options
end