简体   繁体   English

Rails无法将页面呈现为json

[英]Rails not able to render page as json

I have a URL like this : localhost/events/show?eId=12345.json 我有一个这样的URL: localhost/events/show?eId=12345.json

When I perform : model.find(params[:eId]) 当我执行时: model.find(params[:eId])

It considers .json part of eId and says no id found for 12345.json . 它认为.json的一部分eId ,没有发现ID说12345.json To resolve this issue, I excluded .json from eId and it then shows the html page. 要解决这个问题,我排除.jsoneId ,然后它显示HTML页面。 But I need to be able to also see the .json page. 但是我还需要能够看到.json页面。

So it doesn't recognize that I need to view page as json. 因此,它无法识别我需要将页面查看为json。

尝试localhost/events/show.json?eId=12345

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM