mardi 21 avril 2015

Language Specific Routes For Static Pages in Rails 3

Application using Rails 3.2.8 with below gems

gem 'friendly_id', '~> 4.0'
gem 'globalize3',"0.3.0"
gem 'route_translator'

In controller /app/controllers/home_controller.rb

def static_pages
 # page url is unique and used for finding static pages. 
 # Possible values for params[:page] are about_us, contact_us, 
 # privacy, terms_and_conditions
 @static_page = StaticPage.find_by_page_url(params[:page])
end

In routes.rb file

match "/page/:page" => "home#static_pages", :as => :static_page
localized do
  match "label_vacancies/:job_offer"=>"job_seekers#job_offer"
end

So below are current format of URLs for static pages

http://ift.tt/1IABgDi
http://ift.tt/1J5iwis
http://ift.tt/1IABgTy

But required below format of URLs according language

Aboutus:
http://ift.tt/1J5iwiu
http://ift.tt/1IABg6e
http://ift.tt/1J5izLa
Contact:
http://ift.tt/1IABgTC
http://ift.tt/1J5iwix
http://ift.tt/1J5iwiz

How to achieve this above format of URLs format for staticpages according language. Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire