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
# routes.rb
class OnlyAjaxRequest
def matches?(request)
request.xhr?
end
end
post "/test/suggestions", to: "test#suggestions", :constraints => OnlyAjaxRequest.new
it doesn't get to the controller at all. Taken from railsadventures