Below is the typical respond_to block im using in my controller
respond_to do |format|
format.html # show.html.erb
end
I want to restrict all mime-types except html(lets say).
Couldn’t come up with a solution, how is this possible? This block does nothing if the request is json, this is OK but what I want is to redirect any requests that are not html.
Thanks
The
formatobject yielded byrespond_tohas all of the usual mime types (html, js, xml, etc), and it also has a catch-all mime typeanythat will handle everything else. So, in this case:will use default rendering for html, and will redirect for everything else. See the docs for (a tiny bit) more information: http://apidock.com/rails/ActionController/MimeResponds/respond_to