服务于轨道静态JSON对象文件 [英] Serve a static JSON object file in rails

查看:137
本文介绍了服务于轨道静态JSON对象文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何成为一个静态的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"

这篇关于服务于轨道静态JSON对象文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆