Method: Godmin::Helpers::Tables#column_value

Defined in:
lib/godmin/helpers/tables.rb

#column_value(resource, attribute) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/godmin/helpers/tables.rb', line 24

def column_value(resource, attribute)
  partial_override "#{controller_path}/columns/#{attribute}", resource: resource do
    column_value = resource.send(attribute)

    if column_value.is_a?(Date) || column_value.is_a?(Time)
      column_value = l(column_value, format: :long)
    end

    if column_value.is_a?(TrueClass) || column_value.is_a?(FalseClass)
      column_value = t(column_value.to_s)
    end

    column_value
  end
end