Names and nested routes?!?

Hi Guys,

I have the following route to show the articles for a selected service
in my application.

http://localhost:3000/services/4/articles

I want to be able to have a route to the service name rather than the
route such as the following.

http://localhost:3000/services/clothes/articles

I thought something like the following in the routes.rb file would be
the way forward?

map.connect ‘clothes/’, :controller => ‘articles’, :action => “index”,
:service_id => ‘4’

Many thanks in advance

Dave

On Mon, Dec 8, 2008 at 1:55 PM, Dave S.
[email protected] wrote:

http://localhost:3000/services/clothes/articles

Assuming that the attribute of the Service is called name,
you should define this in your Service model:

def to_param
name
end

for more info, look at this post:

Franz S. wrote:

On Mon, Dec 8, 2008 at 1:55 PM, Dave S.
[email protected] wrote:

http://localhost:3000/services/clothes/articles

Assuming that the attribute of the Service is called name,
you should define this in your Service model:

def to_param
name
end

for more info, look at this post:

Best Online Casino in Australia | Top Licensed Casinos for Gamblers

I used the following code in the end, as I have a field title in the
table.

def to_param
id.to_s+‘-’+title.downcase.gsub(’ ', ‘-’)
end

However it puts the address with the ID at the beginning;

http://localhost:3000/services/1-horse-&-groom/articles

Is there a way I can remove this from the address to tidy it up a bit?