Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 544
  • Last Modified:

customize rails URL

so lets say this is my show page from the story resource:

http://localhost:3000/stories/aerovironment-wins-84-million-order-for-digital-raven-uavs

how do i change "stories" to something else?

i already have this for the index page:

map.news '/news', :controller => 'stories', :action => 'index'

0
depassion
Asked:
depassion
  • 3
  • 2
1 Solution
 
Andrew DoadesIT TechnicianCommented:
Something like this, this is a real route from one of my current rails apps.
It means I can navigate to http://server/download_video/387  and download video "387" for example.

map.doclink '/download_video/:id', :controller => 'customer/sub_categories', :action => 'doclink2'

Andrew
0
 
depassionAuthor Commented:
so:

map.articleshow '/news/:id', :controller => 'stories', :action => 'show'

it doesn't work for me
0
 
Andrew DoadesIT TechnicianCommented:
Hmm.. what's the field name where "aerovironment-wins-84-million-order-for-digital-raven-uavs" comes from?
I'll then do some testing on a local app (unless someone steps in first :) )

Andrew
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
depassionAuthor Commented:
thats from a plugin called friendly_id

gem "friendly_id", "3.1.7"
0
 
depassionAuthor Commented:
it just takes the heading of the story

t.string   "heading"

and in the story model:

has_friendly_id :heading, :use_slug => true
0
 
kristinalimCommented:
It looks like you already have a collection resource set up. It probably looks like this:
map.resources :stories

Open in new window


What version of rails are you using? It doesn't look like it's Rails 3.x. In 2.3.8, you can use the :as option to specify the name generated and recognized in the URL. See the Rails 2.3.8 API, search for "resources" (ActionController::Resources) for more information.
map.resources :stories, :as => 'news'

Open in new window

In a much earlier version, if I remember correctly, it's the :opaque_name option.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now