Rails Routes - Limiting the available formats for a resource

routes, ruby-on-rails

Solution

You just add constraints about format :

resources :photos, :constraints => {:format => /(js|json)/}

Problem

I have a series of resources that I want only available if accessed via the JS format. Rails' route resources gives me the formats plus the standard HTML. Is there a way to specify that only the JS format routes be created?

Original source