Joshua Abbott
2008-Dec-27 03:34 UTC
Best way to create a route that only accepts one format
Hey guys,
I haven''t done this before so I thought I''d ping the mailing
list to see
if anyone has any better ideas than what I''ve come up with.
I want to create a route that looks something like this:
url.com/counter/:id.png
Basically, this will route to the "show" method in the controller, and
should only work if the format requested is .png.
I''m using this controller for other things as well, but any other time
it''s accessed through a nested route:
url.com/users/1/ads/:id
So here''s what I''ve come up with:
map.resources :ads, :only => :show, :as => :counter, :requirements =>
{ :format => :png }
map.resources :users, :has_many => :ads
This seems to be working, however instead of a 404 Not Found being
returned to the browser, it''s returning a 406 Not Acceptable.
Is there any way to generate this route so that unless the format is png
it will return the usual 404 Not Found when a route doesn''t exist?
Thanks,
Josh
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---