module ApplicationHelper def lang_switcher content_tag(:span, class: 'language') do I18n.available_locales.each do |loc| locale_param = request.path == root_path ? root_path(locale: loc) : params.merge(locale: loc).permit(:locale, :page, :key_search) concat link_to content_tag(:figure, "", :class => "flag-icon flag-icon-squared flag-icon-#{loc == :en ? "us" : loc}"), locale_param end end end def iso2human(date) if date begin time = Time.iso8601(date.sub(' ', 'T')) "#{set0(time.day)}/#{set0(time.month)}/#{time.year}" rescue date end end end def url_exist?(url) require 'net/http' begin Net::HTTP.get_response(URI.parse(url)).is_a?(Net::HTTPSuccess) rescue false end end private def set0(value) if value <= 9 "0#{value}" else value end end end