module PopularityContest::ViewHelpers

Public Instance Methods

Private Instance Methods

build_path(content_type, content_id) click to toggle source
# File lib/popularity_contest/view_helpers.rb, line 51
def build_path(content_type, content_id)
  content_type = content_type.to_s.downcase
  uri = []
  uri << "#{Rails.application.routes.url_helpers.popularity_contest_web_path}"
  uri << "#{content_type}"
  uri << "#{content_id}"

  strip_locale_uri(uri.join("/"))
end
redis_connection() click to toggle source
# File lib/popularity_contest/view_helpers.rb, line 69
def redis_connection
  if $redis.present?
    redis = $redis
  elsif @redis.present?
    redis = @redis
  else
    raise 'Unable to find a usable redis instance'
  end
end
strip_locale_uri(path) click to toggle source

Because Billetto have locales in URLs like billetto.dk/da and billetto.dk/en and the paths returned from Rails will include those, and this route:

mount PopularityContest::Web, :at => "hit"

will only bind on: billetto.dk/hit/our/app and not: billetto.dk/en/hit/our/app

# File lib/popularity_contest/view_helpers.rb, line 65
def strip_locale_uri(path)
  path.to_s.gsub(/\/(en|da|no|sv)/i, "")
end