Module: NimbleshopHelper
- Defined in:
- app/helpers/nimbleshop_helper.rb
Instance Method Summary collapse
- #body_class ⇒ Object
- #body_id ⇒ Object
- #display_address(address) ⇒ Object
- #display_page_title ⇒ Object
-
#grouped_options_for_country_state_codes ⇒ Object
returns hash for all countries with subregions like this { ‘CA’ => [[“Alberta”, “AB”], [“British Columbia”, “BC”], [“Manitoba”, “MB”],…], ‘US’ => [[“Alaska”, “AK”], [“Alabama”, “AL”], [“Arkansas”, “AR”], [“American Samoa”, “AS”],…], }.
- #page_title(title) ⇒ Object
- #parent_layout(layout) ⇒ Object
Instance Method Details
#body_class ⇒ Object
29 30 31 |
# File 'app/helpers/nimbleshop_helper.rb', line 29 def body_class %|#{controller.controller_name} #{controller.controller_name}-#{controller.action_name}| end |
#body_id ⇒ Object
3 4 5 |
# File 'app/helpers/nimbleshop_helper.rb', line 3 def body_id "#{params[:controller]}-#{params[:action]}".parameterize end |
#display_address(address) ⇒ Object
7 8 9 10 |
# File 'app/helpers/nimbleshop_helper.rb', line 7 def display_address(address) return if address.nil? address.full_address_array.map { |i| html_escape(i) }.join('<br />').html_safe end |
#display_page_title ⇒ Object
12 13 14 15 16 17 18 |
# File 'app/helpers/nimbleshop_helper.rb', line 12 def display_page_title if @page_title @page_title.html_safe + " — ".html_safe + html_escape(current_shop.name) else Shop.current.name end end |
#grouped_options_for_country_state_codes ⇒ Object
returns hash for all countries with subregions like this
{
'CA' => [["Alberta", "AB"], ["British Columbia", "BC"], ["Manitoba", "MB"],...],
'US' => [["Alaska", "AK"], ["Alabama", "AL"], ["Arkansas", "AR"], ["American Samoa", "AS"],...],
}
38 39 40 41 42 43 |
# File 'app/helpers/nimbleshop_helper.rb', line 38 def Carmen::Country.all.select { |c| c.subregions? }.reduce({}) do |h, country| h[country.alpha_2_code] = country.subregions.map { |r| [r.name, r.code] } h end end |
#page_title(title) ⇒ Object
20 21 22 |
# File 'app/helpers/nimbleshop_helper.rb', line 20 def page_title(title) @page_title = title end |
#parent_layout(layout) ⇒ Object
24 25 26 27 |
# File 'app/helpers/nimbleshop_helper.rb', line 24 def parent_layout(layout) @view_flow.set(:layout,output_buffer) self.output_buffer = render(file: "layouts/#{layout}") end |