Method: StandardView::ApplicationHelper#attribute_value_for

Defined in:
app/helpers/standard_view/application_helper.rb

#attribute_value_for(material, attribute_name) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
# File 'app/helpers/standard_view/application_helper.rb', line 56

def attribute_value_for(material, attribute_name)
  formatted_method_name = "#{attribute_name}_formatted"
  return material.public_send(formatted_method_name) if material.respond_to?(formatted_method_name)

  return material.public_send(attribute_name) if material.class.try(:primary_key) == attribute_name
  return link_to_related(material, attribute_name) if material.relationship_attributes.include?(attribute_name)

  i18n_method_name = "#{attribute_name}_i18n"
  return material.public_send(i18n_method_name) if material.respond_to?(i18n_method_name)

  material.human_attribute_value(attribute_name)
end