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

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -