gpt4 book ai didi

ruby-on-rails - Rails - 将 query_reviewer 与 JSON Web 服务结合使用

转载 作者:行者123 更新时间:2023-12-04 19:36:57 24 4
gpt4 key购买 nike

我正在尝试使用 query_reviewer gem 来分析 mysql 查询。似乎访问输出的唯一方法是将结果注入(inject) View 。我的 Rails 应用程序只返回 JSON 并且没有 View 。

是否有其他方式查看数据?

最佳答案

我从未使用过 gem,但它是 documentation说明将其配置为将输出写入 View 的功能。

config/query_reviewer.yml中:

inject_view: false

然后在生成json的部分,使用query_review_output helper;最好将其转义为 JSON:query_review_output.to_json。这将进入生成 JSON 的 View 。如果没有,请考虑将其添加到 Controller 中的 JSON 输出中:

def show
@my_current_model = MyCurrentModel.find(params[:id])
@output = @my_current_model.to_json
@output.merge!({query_review_output: query_review_output })
render json: @output
end

关于ruby-on-rails - Rails - 将 query_reviewer 与 JSON Web 服务结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16804884/

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