gpt4 book ai didi

ruby-on-rails - Controller 测试中的ActionController::InvalidCrossOriginRequest

转载 作者:行者123 更新时间:2023-12-03 09:01:09 24 4
gpt4 key购买 nike

在运行这样的旧式 Controller 测试时:

    get :edit, id: object.id, format: :js

我的测试在Rails 4.1中开始失败,并出现以下错误:
ActionController::InvalidCrossOriginRequest: Security warning: an embedded <script> tag on another site requested protected JavaScript. If you know what you're doing, go ahead and disable forgery protection on this action to permit cross-origin JavaScript embedding.

最佳答案

对于Rails 5+

get :edit, params: { id: object.id }, xhr: true

关于ruby-on-rails - Controller 测试中的ActionController::InvalidCrossOriginRequest,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24918994/

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