Then you've no choice but a catchall route at the end of routes.rb
that sends everything at that point to products controller.
You will have to deal with more manual approach of url generation.

On 29 November 2010 09:44, Mark Ratjens <[email protected]> wrote:
> The requirement is to have urls of the form
>
> /cars/23
>
> not
>
> /products/cars-23
>
> This will, of course, be my fall-back position if I can't get exactly what
> is wanted.
>
> Also, I'm already using friendly_id ... my id's aren't actually numeric, but
> it doesn't change the problem. I've read though the friendly_id doco ... it
> doesn't seem to help with adapting the url beyond id's and nested id's. I
> have read at least one post where Norman Clark has answered saying that
> friendly_id is not  aimed at solving routing issues.
>
> On Mon, Nov 29, 2010 at 9:35 AM, Andy Shen <[email protected]> wrote:
>>
>> You could consider mapping the following route to products controller
>>
>> /products/:type/:id
>>
>> or have a look into friendly_id, which is along the same concept of
>> to_params, maybe use id like car-23, truck-37, boat-126
>>
>> On 28 November 2010 23:52, Mark Ratjens <[email protected]> wrote:
>> > Suppose I have an ActiveRecord called Product. I can have different
>> > kinds of
>> > products, say "cars", "trucks" and "boats." Because of the nature of the
>> > app, there is no need to subclass product (i.e, the data and behaviour
>> > is
>> > the same) ...
>> >
>> > ... but for SEO reasons I want to be able to generate links in the app
>> > that
>> > include the kind of product, not just "product", for example:
>> >
>> > /cars/23
>> > /trucks/37
>> > /boats/126
>> >
>> > not:
>> >
>> > products/23 etc
>> >
>> > The thing I am tousling with is generating the appropriate link in the
>> > app.
>> > Is there some way I can adapt:
>> >
>> > link_to @product.name, @product
>> >
>> > to automagically generate a link with the right product kind ... or do I
>> > need to do it long-hand, i.e:
>> >
>> > link_to @product.name, :controller => @product.kind, :action => :show,
>> > :id
>> > => :product
>> >
>> > ?
>> >
>> > Thanks in advance
>> >
>> > Mark
>> >
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "Ruby or Rails Oceania" group.
>> > To post to this group, send email to [email protected].
>> > To unsubscribe from this group, send email to
>> > [email protected].
>> > For more options, visit this group at
>> > http://groups.google.com/group/rails-oceania?hl=en.
>> >
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ruby or Rails Oceania" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/rails-oceania?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby or Rails Oceania" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/rails-oceania?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
or Rails Oceania" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rails-oceania?hl=en.

Reply via email to