- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
Controller 中的相关代码如下:
logger.info("Dumping params")
logger.info(params)
logger.info("Dumping initial cost:")
logger.info(@cost)
logger.info("entering if statement")
if params.has_key?("special_edition") && params["special_edition"] == 'yes'
@cost = @cost + 50000
end
logger.info("If we get to here then the first conditional executed correctly")
if params.has_key?("number_of_lids") && params["number_of_lids"].to_i > 0
@cost = @cost + (params["number_of_lids"].to_i * 5000)
end
logger.info("If we get to here then the second conditional executed correctly")
logger.info("printing final cost:")
logger.info(@cost)
当我运行该应用程序时,出现 500 错误。检查日志文件(测试日志文件),我看到以下内容:
Dumping params
{"utf8"=>"✓", "special_edition"=>"yes", "number_of_lids"=>"3", "action"=>"create"}
Dumping initial cost:
350000
entering if statement
Completed 500 Internal Server Error in 1922ms
如果我进入控制台(rails 控制台),并运行这段代码(从日志文件中获取的值:
params = {"utf8"=>"✓", "special_edition"=>"yes", "number_of_lids"=>"3", "action"=>"create"}
@cost = 350000
if params.has_key?("special_edition") && params["special_edition"] == 'yes'
@cost = @cost + 50000
end
if params.has_key?("number_of_lids") && params["number_of_lids"].to_i > 0
@cost = @cost + (params["number_of_lids"].to_i * 5000)
end
然后我得到@cost: 415000 的正确结果
我可能会收到 500 错误的任何想法?
有几个回复提到不同之处在于我正在初始化 @cost 但不是在 Controller 中进行。不包括初始化@cost 的代码,因为它已经正确初始化。我包含了一段将@cost 记录到日志文件的代码,我正在控制台中使用我从日志文件中为@cost 获取的值对其进行初始化(请参阅我的代码,第 3 行和第 4 行,然后是日志文件第 3 和 4 行)
我尝试使用评论功能,但 stackoverlfow 给我一条错误消息。
事实证明,应用程序中的另一个模块正在读取 interget @cost 并将其转换为字符串。这被应用程序中的另一个错误掩盖了,因此较早的测试失败了。这个故事的寓意:回归测试是必不可少的。使用@cost.to_i 解决了这个问题
最佳答案
显式@cost 初始化的区别。在您的 Controller 操作开始处写入 @cost = 350000
。
关于ruby-on-rails - rails : App fails but code runs fine in console,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13054957/
微调 API 中关于 model 属性的 OpenAI 文档说明有点令人困惑: model The name of the base model to fine-tune. You can selec
微调 API 中关于 model 属性的 OpenAI 文档说明有点令人困惑: model The name of the base model to fine-tune. You can selec
当涉及到语言模型(LLM)的教学微调时,什么时候应该选择有监督的微调培训器(SFTTrainer)而不是常规的Transformers培训器?据我所知,常规的Transformers培训人员通常指的是
最近在处理后台数据时需要实现文件上传.考虑到对浏览器适配上采用Fine Uploader. Fine Uploader 采用ajax方式实现对文件上传.同时在浏览器中直接支持文件拖拽[对浏览器版本有
1f45bd1e8577af66a05f5e3fadb0b29 通过ORPO对llama进行微调 前言 ORPO是一种新颖的微调技术,它将传统的监督微调和偏好对齐阶段整合到一个过程中。这减少了训
我希望使用 Fineuploader 为每个上传的项目添加标题/名称。每个附件都会在其旁边显示一个文本框,以便用户可以在按“上传”之前输入标题/名称 like this 我看过了,每个上传请求都会发送
假设我想一次上传多个文件,将 multiple 选项设置为 true 时我可以这样做: var myUploader = new qq.FineUploader({ element: $('#
使用 Fineuploader v3.3 的 jQuery 封装版本。 是否可以使用上传文件夹中已有的文件填充文件列表? 我认为“_addToList(id, name)”应该可以解决问题,但我无法让
log4j.properties log4j.rootLogger=FINE, stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppende
我想在我的小程序中使用 java util 日志记录,日志级别为 FINE 及以下。 我在我的小程序的 jar 中放了一个 logging.properties 文件 handlers= java.u
我的域层需要一个实体具有与之关联的 1:N 图像。 由于 FineUploader 将每个图像作为单独的请求发送,我在第一个请求上创建一个实体(服务器端),并在第一个响应 JSON 中发送回该 ID
关闭。这个问题需要debugging details .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 2年前关闭。 Improve this questio
我阅读了有关使用 Fine Uploader 进行缩放的文档: http://docs.fineuploader.com/features/scaling.html 是否可以仅考虑图片的高度来缩放图片
我正在使用很好的 uploader ,它运行得很好。现在,即使上传成功,它也会重试。这样一来,我就有了四个文件,而不是只有一个。 http://fineuploader.com/ 我的代码:
当我运行 Maven 时,我得到的输出就好像我指定了日志记录级别 FINE 一样,这使得很难找到实际的输出。我还得到了数百行列出显式和隐式绑定(bind)的信息。据我所知我根本没有配置 mvn 。我正
我在我的表单中使用 FineUploader:http://docs.fineuploader.com/branch/master/features/forms.html . 问题是,在我的表单文件中
我已经为此发了几个小时的消息,但无法让它工作。我对fineuploader的实现 $(document).ready(function() { //alert(qq.supportedFeatures
我有一个关于 fine uploader (3.0) 的奇怪问题,它适用于除 ie9 之外的所有浏览器。 没有js错误,就是上传一个0byte失败了。我正在使用 valums php,它在这里失败了:
我正在实现类似 Google Plus 上传窗口的功能,当窗口中的整个灰色区域 (div) 都可以点击时,文件选择器就会出现。 这是我正在尝试做的事情的简单模型代码 (jsfiddle) $(func
我正在使用Fine-uploader(繁体版)试图让用户上传文件到我们自己的服务器。我现在面临的挑战是我应该在正常上传过程之前先从服务器获取 token 。 token 将与每个上传请求/ block
我是一名优秀的程序员,十分优秀!