如何在Mongoid中使用update_attributes for datetime_select helper?

Ton*_*Han 3 ruby-on-rails mongoid

我使用mongodb作为我的数据库和驱动程序mongoid.

我的一个模型Bill的字段是local_time,我在视图中使用了datetime_select:

.ym-fbox-select                    
  = f.label :local_time, "Time"
  = f.datetime_select :local_time 
Run Code Online (Sandbox Code Playgroud)

create行动是OK.但update行动不是.错误是这样的:

(eval):1: syntax error, unexpected tINTEGER, expecting ')'
    def local_time(1i)=(value)
Run Code Online (Sandbox Code Playgroud)

而且update是:

def update                                   
 @bill = Bill.find(params[:id])             

 respond_to do |format|                     
   if @bill.update_attributes(params[:bill])
Run Code Online (Sandbox Code Playgroud)

所以我想知道如何更新该local_time字段?

Pet*_*ich 5

添加include Mongoid::MultiParameterAttributes到您的模型,就像您对Timestamps一样.

请参阅:https://github.com/mongoid/mongoid/issues/892#issuecomment-1247311