renaming routes (map, link_to, to_param) in rails -


I'm having a little issue ... I'm setting up a Rail app that is serving a German website. To use internal plural features, I put all my models in English (Example Model " JobDescription ") Now, if I use " http://mysite.com/job_descriptions/ I call "", so I get all my job descriptions .... so far, because I want to enter my URL The English word " job_descriptions " was not wanted, I put the following in my own path.

  map.german_term '/ german_term',: controller = & gt; 'Job_descriptions' ,: Action => Index 'map.german_term' / german_term /: id ',: Controller = & gt;' Job_descriptions ',: verb = & gt; show'  

If I call " http://mysite.com/german_term/ " or " http://mysite.com/german_term/283 " I get all my job description , which is fine.

However, in order to make the URL more SEO friendly, I want to exchange the id in a more user-friendly slug in the URL, I type my job_description.rb The following is entered in:

  def to_param "# {id} - # {name.gsub (/ [^ a-z0- 9] + / i, '-'}}" End  

That is, whenever I use " job_description_path " any link_to method, my URL is like "" Presents for some things.

However, and this is where I got stuck, " http: // mysite / german_term / 13-my-job-description-title ". I was already trying to exchange " job_description_path " in the "link_to" code with " german_term_path ", but only " http : // mysite / german_term/13 "/ code>". Obviously, I have found a workaround that is not called to_param :

  & lt;% = Link_to job_description.name, german_term_path (job_description.to_param)%>  

but it's harder to replace all link_to calls in my code

Any ideas?!?

What do I want " job_description " by " german_term "

Regards,

Sebastien

I think that you need to be able to use helpers from the comfort of your way to get whatever you want.

In that situation, it will not relate much more (assuming You are mapped as a resource in the form of a job). Leave your to_param and change your JobDescriptions path like something like:

  map.resources: job_descriptions ,: as = & gt; 'German_term'  

Hope this helps!


Comments