gpt4 book ai didi

ruby-on-rails - response_with - 如何回复文本

转载 作者:行者123 更新时间:2023-12-03 16:12:35 25 4
gpt4 key购买 nike

我在 rails 应用程序中使用 response_to 和respond_with,但在一个用例中,我只需要对一种资源格式(:json)用文本进行响应......但我找不到如何做到这一点...

我想要这样的东西(我知道这行不通)

def create
...
respond_with(:json, render :text => "Successfully Done!")
end

任何的想法??

谢谢!

最佳答案

看来这可能就是你要找的:

def create
respond_to do |format|
format.html
format.json { render :text => "Successfully Done!" }
end
end

关于ruby-on-rails - response_with - 如何回复文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12805071/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com