Rails - Rendering a page in JSON based conditionally on the URL? -
i have page want conditionally render in json based on if there either .json or /.json @ end of url, how reddit it, example https://www.reddit.com/r/pics/.json renders page in json. rendering page in json easy enough render json: @some_data
, i'm not sure how make conditionally based on url. how go setting up?
first of define routes resources
resources :xvaziris
just append url .json
here example:
http://localhost:3000/xvaziris.json
Comments
Post a Comment