Module: GacoCms::ApplicationHelper
- Defined in:
- app/helpers/gaco_cms/application_helper.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.page_url_for(id) ⇒ Object
9 10 11 |
# File 'app/helpers/gaco_cms/application_helper.rb', line 9 def page_url_for(id) Rails.application.routes.url_helpers.gaco_cms_page_path(page_id: id) end |
.translated_value_for(data) ⇒ Object
19 20 21 22 23 24 |
# File 'app/helpers/gaco_cms/application_helper.rb', line 19 def self.translated_value_for(data) data = { en: data } unless data.is_a?(Hash) data[I18n.locale].presence || data[I18n.default_locale].presence || data.values.find(&:present?) end |
Instance Method Details
#form_title(model) ⇒ Object
5 6 7 |
# File 'app/helpers/gaco_cms/application_helper.rb', line 5 def form_title(model) model.id ? "Edit #{model.class.human_name}" : "New #{model.class.human_name}" end |
#required_label(form, key, args = {}, &block) ⇒ Object
14 15 16 17 |
# File 'app/helpers/gaco_cms/application_helper.rb', line 14 def required_label(form, key, args = {}, &block) append = args[:optional] ? capture { block&.call } : "<small>#{capture { block&.call }}(*)</small>" form.label(key, args) { |l| "#{args[:label] || l} #{append}".html_safe } # rubocop:disable Rails/OutputSafety end |