What do I need to change in the code below to make it link to a view rendered as json?
<%= link_to 'JSON Link', @mymodel %>
So I’d like to generate the following url
http://localhost:3000/mymodels/1.json
instead of
http://localhost:3000/mymodels/1
(These urls both work as expected.)
To do this, you must specify the format:
The URL helper methods can be retrieved by running:
The first column is the name of the helper method, on which you should append either
_pathor_url, the latter will generate an absolute URL.More information is in the Guide To Rails Routing