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?
+1
A:
You just add constraints about format :
resources :photos, :constraints => {:format => /(js|json)/}
shingara
2010-09-09 19:06:44
Unless I'm doing something wrong, that still allows me to access /photos as :html. I get the missing template message, when I'd expect a missing route exception. Thoughts?
Eric M.
2010-09-09 20:51:00
Shouldn't that be `/(js|json)/`?
Garrett
2010-09-09 20:55:58
Yeah, I caught that and changed it. Still doesn't work for me. I have resources :members, :controller => 'homes/members', :constraints => {:format => /js/}
Eric M.
2010-09-09 21:29:04