服务于轨道静态JSON对象文件服务于、静态、轨道、对象

2023-09-10 17:41:05 作者:芐①跕圉湢

我如何成为一个静态的JSON对象从轨文件? (我要访问它在一个Ajax调用)?

How do I serve a static JSON object from a file in rails? (I want to access it in an ajax call)?

什么是最好的方法是什么?

What is the best method?

推荐答案

只需将要在一个变量来渲染一下,然后用渲染:JSON =>变量 有合理的默认值列表,http://stardict.sourceforge.net/Dictionaries.php下载,等等...

Just place what you want to render in a variable, then use render :json => variable There are sensible defaults for lists, dicts, etc...

请参阅此: http://guides.rubyonrails.org/layouts_and_rendering.html

项:2.2.8渲染JSON

Item: "2.2.8 Rendering JSON"

 
精彩推荐
图片推荐