ruby-on-rails – 不能将datetime_select与Mongoid一起使用
发布时间:2020-12-16 19:02:43 所属栏目:百科 来源:网络整理
导读:每次我尝试在视图中使用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::Attribut
每次我尝试在视图中使用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 我已经尝试过分配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. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |