gpt4 book ai didi

ruby-on-rails - 不能将 datetime_select 与 Mongoid 一起使用

转载 作者:IT老高 更新时间:2023-10-28 13:16:28 25 4
gpt4 key购买 nike

每次我尝试在 View 中使用 Datetime_select 时,应用程序都会引发属性错误。

Mongoid::Errors::UnknownAttribute:

Problem:
Attempted to set a value for 'fromtime(1i)' which is not allowed on the model Event.
Summary:
Without including Mongoid::Attributes::Dynamic in your model and the attribute does not already exist in the attributes hash, attempting to call Event#fromtime(1i)= for it is not allowed. This is also triggered by passing the attribute to any method that accepts an attributes hash, and is raised instead of getting a NoMethodError.
Resolution:
You can include Mongoid::Attributes::Dynamic if you expect to be writing values for undefined fields often.

我最常遇到的解决方案是在模型中包含 Mongoid::MultiParameterAttributes。不幸的是,该模块已被删除! https://github.com/mongoid/mongoid/issues/2954

我已尝试 fork gem 并重新添加 MultiparameterAttributes 模块,但 gem 不会从 lib 文件中读取代码。有什么方法可以将 DateTime_select 与 Mongoid 一起使用?

最佳答案

<罢工>您需要在您的 Mongoid 模型中包含 include Mongoid::MultiParameterAttributes

this GitHub issue on the problem .

我在任何地方都找不到它的文档。~

这会教我阅读不正确! This gem seems to be the solution though .

关于ruby-on-rails - 不能将 datetime_select 与 Mongoid 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16907529/

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