Module: PagesHelper

Defined in:
app/helpers/pages_helper.rb

Instance Method Summary collapse

Instance Method Details

#agreement_text(key) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/helpers/pages_helper.rb', line 40

def agreement_text(key)
  Rails.cache.fetch "terms_text_#{key}_#{I18n.locale}", expires_in: 4.hours do
    # id = Settings["#{key}_id".gsub(/(?:_id)+$/, '_id')]
    data = {
      link: try(:terms_page_path)
    }
    TranslationCms.term_pages.each do |kind|
      data[kind.to_sym] = try("#{kind}_page_path")
    end
    I18n.t(key, data)
  end
end

#trackable_key(structure) ⇒ Object



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

def trackable_key(structure)
  key = structure.track_key if defined? structure.track_key
  key ||= "trackable_key[#{[structure.class.name, structure.id].join('|').hash}]"
  key
end

#trackable_tag(structure, html_options = {}, &block) ⇒ Object



16
17
18
19
20
21
22
23
# File 'app/helpers/pages_helper.rb', line 16

def trackable_tag(structure, html_options = {}, &block)
  html_options = (html_options || {}).stringify_keys
  html_options[:style] ||= 'display:none;'
  html_options[:data] ||= {}
  html_options[:data][:set_key] ||= trackable_key(structure)
  html_options[:data][:set_value] ||= trackable_value(structure)
  (:span, nil, html_options, &block)
end

#trackable_value(structure) ⇒ Object



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

def trackable_value(structure)
  value = structure.track_value if defined? structure.track_value
  value ||= "track_#{(structure.updated_at || structure.created_at).to_i}".hash
  value
end