respond_to :json
def create
respond_with('test')
end
我只是做了一些测试,上面给出了一个错误:
未定义方法“test_url”#
为什么要尝试将 test 转换为 url?这是一个错误吗?
最佳答案
JSON 对象必须有两个八位字节,如键和值。您不能只通过字符串发送。
试试这个:
respond_with(:message => "test")
关于ruby-on-rails - respond_with json 奇怪之处,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5224309/