Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 142633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:58:04+00:00 2026-05-11T07:58:04+00:00

I’m having a little issue…I setup a rails application that is to serve a

  • 0

I’m having a little issue…I setup a rails application that is to serve a german website. To make use of Rails’ internal pluralization features, I kept all my models in english (e.g. the model ‘JobDescription‘). Now, if I call ‘http://mysite.com/job_descriptions/‘, I get all my job_descriptions….so far, so good. Because I didn’t want the english term ‘job_descriptions‘ in my url, I put the following into my routes.rb

map.german_term '/german_term', :controller => 'job_descriptions', :action => 'index' map.german_term '/german_term/:id', :controller => 'job_descriptions', :action => 'show' 

If I call ‘http://mysite.com/german_term/‘ or ‘http://mysite.com/german_term/283‘ I get all my job_descriptions, which is fine.

However, to make the URL more SEO friendly, I’d like to exchange the id for a more userfriendly slug in the URL. Thus, I put the following in my job_description.rb:

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

which, whenever I use ‘job_description_path‘ in any link_to method, renders my URLs out to something like ‘http://mysite/job_descriptions/13-my-job-description-title‘.

However, and this is where I’m stuck, I’d like to get ‘http://mysite/german_term/13-my-job-description-title‘. I already tried to exchange the ‘job_description_path‘ with ‘german_term_path‘ in the link_to code, but that only generates ‘http://mysite/german_term/13‘. Obviously, to_param isn’t called. One workaround I found is to build the link with:

<%= link_to job_description.name, german_term_path(job_description.to_param) %> 

But that’s rather tedious to change all the link_to calls in my code. What I want is to replace ‘job_description‘ by ‘german_term‘ whenever it occurs in a URL.

Any thoughts?!?

Regards,

Sebastian

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T07:58:04+00:00Added an answer on May 11, 2026 at 7:58 am

    I think you’re going to need to use the restful route helpers to get what you want.

    In that case, it wouldn’t take much re-factoring (assuming you’ve mapped JobDescriptions as a resource). Leave your to_param as is and change your JobDescriptions route to something like the following:

    map.resources :job_descriptions, :as => 'german_term' 

    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.