I have the following routes:
resources :tags do
collection do
get 'autocomplete', :constraints => { :format => 'js' }
end
end
I would like this to only respond to JS requests (it’s only for jQuery autocomplete), for a regular HTML request I think it should be a 404 response, or at least a redirect.
Instead, all requests are converted to JS format by the route, so an HTML request gets a json hash.
It isn’t absolutely critical, but I would be much happier if I could cleanly restrict this route so that HTML requests to it were not allowed. How should that be handled?
In
TagsController#autocomplete, do the following: