mongoid - 动态日期/时间属性 - 多参数异常
我有一个名为 Form
的模型,它根据用户要求获取字段,例如,如果用户将文本字段放入表单中,则在表单模型中创建一个属性用于存储字符串数据。
同样,我想存储日期/时间和日期时间值。因此,我在表单模型中添加了
include Mongoid::MultiParameterAttributes
,因为日期和时间值是从多个属性中提交的。
但是我在控制器创建操作中遇到 Mongoid::MultiParameterAttributes::Errors::MultiparameterAssignmentErrors
异常,在 @form = Form.new(params[:form])
行上
def create
@form = Form.new(params[:form])
if @form.save
redirect_to(form_path(@form))
else
redirect_to :action => "new"
end
end
我该如何度过这个难关。 请帮忙
I have a model named Form
, which get fields as per user requirement, eg if user puts text field in the form then a attribute is created in Form model for storing string data.
Similarly I want to store date/time and datetime values. So I added
include Mongoid::MultiParameterAttributes
in the form model, because date and time values are submitted from for in multiple attributes.
But I get Mongoid::MultiParameterAttributes::Errors::MultiparameterAssignmentErrors
exception in the controller create action, on the line @form = Form.new(params[:form])
def create
@form = Form.new(params[:form])
if @form.save
redirect_to(form_path(@form))
else
redirect_to :action => "new"
end
end
How do I get through this.
Please Help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
修改您的
Form
类,使其如下所示。Modify your
Form
class so it looks like the one below.ruby 驱动程序只能序列化 Time 对象。那可能是你的问题。
The ruby driver can only serialize Time objects. That might be your problem.