Module: Editus::HomeHelper

Defined in:
app/helpers/editus/home_helper.rb

Instance Method Summary collapse

Instance Method Details

#enums(record, col) ⇒ Object



31
32
33
# File 'app/helpers/editus/home_helper.rb', line 31

def enums record, col
  record.defined_enums[col].keys.join(", ")
end

#field_enums?(record, col) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'app/helpers/editus/home_helper.rb', line 27

def field_enums? record, col
  record.defined_enums.key?(col.to_s) && record.defined_enums[col].present?
end

#field_tag(record, col, *args) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'app/helpers/editus/home_helper.rb', line 7

def field_tag record, col, *args
  case record.type_of_col(col)
  when :datetime
    text_field_tag(*args, placeholder: "YYYY-MM-DD HH:mm:ss UTC")
  when :boolean
    safe_join [hidden_field_tag(args.first, "false", id: nil),
      check_box_tag(args.first, "true", record.try(col))]
  else
    text_field_tag(*args)
  end
end

#parameters(proxy, method) ⇒ Object



19
20
21
22
23
24
25
# File 'app/helpers/editus/home_helper.rb', line 19

def parameters proxy, method
  return [] unless proxy.respond_to?(method)

  proxy.method(method).parameters.filter_map do |(type, value)|
    value if type.in?(%i[req opt])
  end
end

#path_active?(path) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
# File 'app/helpers/editus/home_helper.rb', line 3

def path_active? path
  request.original_url.include?(path)
end