Module: ProfileFieldHelper

Defined in:
app/helpers/profile_field_helper.rb

Instance Method Summary collapse

Instance Method Details

args:

profileable
profile_field_type
profile_section


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/helpers/profile_field_helper.rb', line 22

def link_to_add_profile_field( args )
  raise "expected argument 'profileable'" unless args[:profileable].present?
  raise "expected argument 'profile_field_type'" unless args[:profile_field_type].present?
  raise "expected argument 'profile_section'" unless args[:profile_section].present?
  label_in_english_with_underscores = args[:profile_field_type].demodulize.underscore
  link_to( I18n.t(label_in_english_with_underscores),
           url_for( :controller => :profile_fields,
                    :profileable_id => args[:profileable].id,
                    :profileable_type => args[:profileable].class.name,
                    :profile_field => {:type => args[:profile_field_type]},
                    :section => args[:profile_section],
                    :label => label_in_english_with_underscores
                  ),
           :id => "add_#{label_in_english_with_underscores}_field",
           :remote => true,
           :method => 'post'
         )
end

#profile_field_li(profile_field, options = {}) ⇒ Object



3
4
5
6
7
8
# File 'app/helpers/profile_field_helper.rb', line 3

def profile_field_li( profile_field, options = {} )
  # options: 
  #   lock_label: true/false, default: false
  #   no_remove: true/false, default: false
  render partial: 'profile_fields/profile_field', locals: {profile_field: profile_field}.merge(options)
end

#profile_field_lis(profile_fields, options = {}) ⇒ Object



10
11
12
13
14
# File 'app/helpers/profile_field_helper.rb', line 10

def profile_field_lis( profile_fields, options = {} )
  profile_fields.collect do |profile_field|
    profile_field_li(profile_field, options)
  end.join.html_safe
end