Module: Voluntary::ShowHelper
- Defined in:
- app/helpers/voluntary/show_helper.rb
Instance Method Summary collapse
- #show_actions(options = {}) ⇒ Object
- #show_association(association) ⇒ Object
- #show_associations(*associations) ⇒ Object
- #show_attribute(attribute, options = {}) ⇒ Object
- #show_attributes(*attributes) ⇒ Object
Instance Method Details
#show_actions(options = {}) ⇒ Object
56 57 58 59 60 61 62 63 64 65 |
# File 'app/helpers/voluntary/show_helper.rb', line 56 def show_actions( = {}) result = content_tag :dt, raw(' ') result += content_tag :dd, render( partial: 'shared/resource/actions', locals: { type: root_model_class_name(resource).tableize, resource: resource, namespace: [:namespace] } ) raw result end |
#show_association(association) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/helpers/voluntary/show_helper.rb', line 26 def show_association(association) if association.to_s == association.to_s.pluralize return show_attribute( association, title: t("#{association}.index.title"), value: raw(resource.send(association).map{|a| link_to a.name, a}.join(', ')) ) end title = if general_attribute?(:parent) t("attributes.#{association}") else if resource.send(association) t("activerecord.models.#{root_model_class_name(resource.send(association)).underscore}") else t("activerecord.models.#{association}") end end if resource.send(association) show_attribute( association, title: title, value: link_to(resource.send(association).try(:name), resource.send(association)) ) else '' end end |
#show_associations(*associations) ⇒ Object
18 19 20 21 22 23 24 |
# File 'app/helpers/voluntary/show_helper.rb', line 18 def show_associations(*associations) result = '' associations.each {|association| result += show_association association} raw result end |
#show_attribute(attribute, options = {}) ⇒ Object
11 12 13 14 15 16 |
# File 'app/helpers/voluntary/show_helper.rb', line 11 def show_attribute(attribute, = {}) title = [:title] || attribute_translation(attribute) value = [:value] || resource.send(attribute) value.blank? ? '' : content_tag(:dt, title) + content_tag(:dd, value) end |
#show_attributes(*attributes) ⇒ Object
3 4 5 6 7 8 9 |
# File 'app/helpers/voluntary/show_helper.rb', line 3 def show_attributes(*attributes) result = '' attributes.each {|attribute| result += show_attribute attribute} raw result end |