Files
grecia/app/helpers/application_helper.rb
Fernando Seror a89d621d1d Allow locale to be set through the front-end
* Store the last used locale in the session
* Allow home page to be identified in helpers even when containing
  parameters
* Create initializer to explicitly set the available locales, the
  default and the load_path
2015-08-05 15:43:39 -05:00

26 lines
583 B
Ruby

module ApplicationHelper
def tags(debate)
debate.tag_list.sort.map { |tag| link_to sanitize(tag), debates_path(tag: tag) }.join('').html_safe
end
def percentage(vote, debate)
return if debate.total_votes == 0
debate.send(vote).percent_of(debate.total_votes).to_s + "%"
end
def home_page?
# Using path because fullpath yields false negatives since it contains
# parameters too
request.path == '/'
end
def header_css
home_page? ? '' : 'results'
end
def available_locales_to_switch
I18n.available_locales - [I18n.locale]
end
end