Module: ActionAdmin::AdminHelper
- Defined in:
- app/helpers/action_admin/admin_helper.rb
Instance Method Summary collapse
- #admin_action_title(action = nil) ⇒ Object
- #admin_app_name ⇒ Object
- #admin_meta_tags ⇒ Object
- #admin_present(record, presenter = nil) ⇒ Object
- #admin_present_many(records, presenter = nil) ⇒ Object
- #admin_render_template(fallback) ⇒ Object
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_name ⇒ Object
3 4 5 |
# File 'app/helpers/action_admin/admin_helper.rb', line 3 def admin_app_name ActionAdmin.config.app_name end |
#admin_meta_tags ⇒ Object
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 = { 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' } 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 = template.except(:partial) render partial, end |