How to add :format options to a named route in Rails?

Posted by Alfred Nerstu on Stack Overflow See other posts from Stack Overflow or by Alfred Nerstu
Published on 2010-03-13T14:40:50Z Indexed on 2010/03/13 14:45 UTC
Read the original article Hit count: 191

Filed under:
|
|
|

I've got a named route called profile and I would like to be able to access it as json. But when I look at my rake routes output I see that the (.:format) is missing. How do I add it to a named route?

user GET    /users/:id(.:format)    {:action=>"show", :controller=>"users"}
profile     /:username              {:action=>"show", :controller=>"users"}

Thanks in advance!

© Stack Overflow or respective owner

Related posts about format

Related posts about named-routing