Solved

customize rails URL

Posted on 2011-09-20
6
489 Views
Last Modified: 2012-05-12
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
Comment
Question by:depassion
  • 3
  • 2
6 Comments
 
LVL 10

Expert Comment

by:Andrew Doades
ID: 36567741
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
 

Author Comment

by:depassion
ID: 36567790
so:

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

it doesn't work for me
0
 
LVL 10

Expert Comment

by:Andrew Doades
ID: 36567808
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:depassion
ID: 36567827
thats from a plugin called friendly_id

gem "friendly_id", "3.1.7"
0
 

Author Comment

by:depassion
ID: 36567871
it just takes the heading of the story

t.string   "heading"

and in the story model:

has_friendly_id :heading, :use_slug => true
0
 
LVL 4

Accepted Solution

by:
kristinalim earned 500 total points
ID: 36585364
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Rails installation ? 6 829
How to Open a .RHTML File on Windows 1 343
Rake errors while installing gitorious 10 716
Instaling Ruby 3 304
I recently rediscovered rails when I needed a holiday project and decided to build a management dashboard for the company where I work.  With it being a project done in my free time, I could focus my time on learning the basics rather than trying to…
Article by: narshlob
If you've ever programmed in Ruby and have come across either a proc or a lambda, you might have been wondering what the difference is between the two and when you would use one over the other. This article will try to explain the difference between…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now