This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
begin | |
require 'bundler/inline' | |
rescue LoadError => e | |
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler' | |
raise e | |
end | |
gemfile(true) do | |
source 'https://rubygems.org' | |
# Activate the gem you are reporting the issue against. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApplicationHelper | |
def method_missing(meth, *args, &blk) | |
if (match = meth.to_s.match(/(.+)_path$/)).present? | |
meth = "#{I18n.locale}_#{meth}" | |
raise NoMethodError, meth unless respond_to?(meth) | |
send(meth, *args) | |
else | |
super | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
en: | |
named_routes: | |
article: '/news/:y/:m/:d/:article_slug(/:country_slug)(/:page)' | |
articles: '/news(/:country_slug)(/:page)' | |
country_services: '/products-and-services' | |
country_service: '/products-and-services/:service_slug' | |
fr: | |
named_routes: | |
article: '/nouvelles/:y/:m/:d/:article_slug(/:country_slug)(/:page)' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Example::Application.routes.draw do | |
REGEX_ID = /[1-9]\d*/ | |
REGEX_COUNTRY_SLUG = /[a-zà-ÿ\-]+/ | |
REGEX_SLUG = /[a-zà-ÿ\d\-]+/ | |
REGEX_LOCALE = /#{I18n.available_locales.join('|')}/ | |
def t_route name, locale | |
I18n.t("named_routes.#{name}", :locale => locale) |