lib/generators/dry_crud/templates/app/helpers/standard_helper.rb
# Formats an arbitrary attribute of the given ActiveRecord object.
# If no specific format_{type}_{attr} or format_{attr} method is found,
# formats the value as follows:
# If the value is an associated model, renders the label of this object.
# Otherwise, calls format_type.
Formats an arbitrary attribute of the given ActiveRecord object.
If no specific format_{type}_{attr} or format_{attr} method is found,
formats the value as follows:
If the value is an associated model, renders the label of this object.
Formats an arbitrary attribute of the given ActiveRecord object . If no specific format_ { type } _ { attr } or format_ { attr } method is found formats the value as follows : If the value is an associated model renders the label of this object .
def format_attr(obj, attr)
    format_type_attr_method = obj.class.respond_to?(:model_name) ? :"format_#{obj.class.model_name.underscore}_#{attr.to_s}" : :"format_#{obj.class.name.underscore}_#{attr.to_s}"
    format_attr_method = :"format_#{attr.to_s}"
    if respond_to?(format_type_attr_method)
      send(format_type_attr_method, obj)
    elsif respond_to?(format_attr_method)
      send(format_attr_method, obj)
    elsif assoc = association(obj, attr, :belongs_to)
      format_assoc(obj, assoc)
    elsif assoc = association(obj, attr, :has_many, :has_and_belongs_to_many)
      format_many_assoc(obj, assoc)
    else
      format_type(obj, attr)
    end
  end
def format_attr ( obj , attr ) format_type_attr_method = obj . class . respond_to? ( :model_name ) ? :" format_ #{ obj . class . model_name . underscore } _ #{ attr . to_s } " : :" format_ #{ obj . class . name . underscore } _ #{ attr . to_s } " format_attr_method = :" format_ #{ attr . to_s } " if respond_to? ( format_type_attr_method ) send ( format_type_attr_method , obj ) elsif respond_to? ( format_attr_method ) send ( format_attr_method , obj ) elsif assoc = association ( obj , attr , :belongs_to ) format_assoc ( obj , assoc ) elsif assoc = association ( obj , attr , :has_many , :has_and_belongs_to_many ) format_many_assoc ( obj , assoc ) else format_type ( obj , attr ) end end
Formats an arbitrary attribute of the given ActiveRecord object.
Formats an arbitrary attribute of the given ActiveRecord object .
obj
attr