| Module | ApplicationHelper |
| In: |
app/helpers/application_helper.rb
|
Takes a hash with pages and tells whether the current page is among them. The keys must be controller names and their value must be an array of action names. If the array is empty, every action is supposed to be valid.
# File app/helpers/application_helper.rb, line 57
57: def active_page?(pages = {})
58: is_active = pages.include?(params[:controller])
59: is_active = pages[params[:controller]].include?(params[:action]) if is_active && !pages[params[:controller]].empty?
60: is_active
61: end
Is the current page the home page? This is used to display further information (like the endoint url) in the <head>
# File app/helpers/application_helper.rb, line 19
19: def home_page?
20: active_page? 'info' => ['index']
21: end
Is the current page an identity page? This is used to display further information (like the endoint url) in the <head>
# File app/helpers/application_helper.rb, line 13
13: def identity_page?
14: active_page? 'accounts' => ['show']
15: end
# File app/helpers/application_helper.rb, line 7 7: def label_tag(field, text = nil, options = {}) 8: content_tag :label, text ? text : field.to_s.humanize, options.reverse_merge(:for => field.to_s) 9: end
Renders a navigation element and marks it as active where appropriate. See active_page? for details
# File app/helpers/application_helper.rb, line 50
50: def nav(name, url, pages = nil, active = false)
51: content_tag :li, link_to(name, url), :class => (active || (pages && active_page?(pages)) ? 'act' : nil)
52: end
# File app/helpers/application_helper.rb, line 3 3: def page_title 4: @page_title ? "#{@page_title} | #{APP_CONFIG['name']}" : APP_CONFIG['name'] 5: end
Custom label names for request properties (like SReg data)
# File app/helpers/application_helper.rb, line 24
24: def property_label_text(property)
25: case property.to_sym
26: when :fullname then 'Full name'
27: when :dob then 'Birth date'
28: when :address_business then 'Address'
29: when :address_additional then 'Additional'
30: when :address_additional_business then 'Additional'
31: when :postcode_business then 'Postcode'
32: when :city_business then 'City'
33: when :state_business then 'State'
34: when :country_business then 'Country'
35: when :im_aim then 'AIM'
36: when :im_icq then 'ICQ'
37: when :im_msn then 'MSN'
38: when :im_yahoo then 'Yahoo'
39: when :im_jabber then 'Jabber'
40: when :im_skype then 'Skype'
41: when :image_default then 'Image URL'
42: when :web_default then 'Website URL'
43: when :web_blog then 'Blog URL'
44: else property.to_s.humanize
45: end
46: end