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 

json example


Comments

Popular posts from this blog

PHP while loop dynamic rowspan -

timer - Java TimerTask cancel -

android - How to read a column value in parse.com without accessing an object or a pointer -