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.
