Mỗi khi tôi cố gắng sử dụng Datetime_select trong chế độ xem, ứng dụng sẽ phát ra lỗi thuộc tính.Không thể sử dụng datetime_select với Mongoid
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.
Giải pháp tôi thường gặp nhất là bao gồm Mongoid :: MultiParameterAttributes trong mô hình. Rất tiếc là mô-đun đã bị xóa! https://github.com/mongoid/mongoid/issues/2954
Tôi đã thử forking đá quý và thêm lại mô-đun MultiparameterAttributes, nhưng đá quý sẽ không đọc mã từ tệp lib. Có cách nào để sử dụng DateTime_select với Mongoid?
bạn có thể cung cấp thêm một số thông tin về cấu trúc dữ liệu của bạn và cách bạn cố truy cập dữ liệu của mình không? – xlembouras