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'

depassionAsked:
Who is Participating?
 
kristinalimConnect With a Mentor Commented:
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
 
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
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
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
 
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
All Courses

From novice to tech pro — start learning today.