2013-06-03 5 views
8

के साथ डेटाटाइम_सेलेक्ट का उपयोग नहीं कर सकता हर बार जब मैं एक दृश्य में डेटाटाइम_क्लेक्ट का उपयोग करने का प्रयास करता हूं, तो ऐप एक विशेषता त्रुटि फेंकता है।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. 

मैं जिस समाधान में अक्सर आया हूं वह मॉडल में Mongoid :: MultiParameterAttributes शामिल करना था। दुर्भाग्यवश कि मॉड्यूल हटा दिया गया है! https://github.com/mongoid/mongoid/issues/2954

मैंने मणि को तोड़ने और मल्टीपार्मेटर एट्रिब्यूट मॉड्यूल को दोबारा जोड़ने की कोशिश की है, लेकिन मणि lib फ़ाइल से कोड नहीं पढ़ेगा। क्या Mongoid के साथ DateTime_select का उपयोग करने का कोई तरीका है?

+0

क्या आप अपने डेटा की संरचना और आप अपने डेटा तक पहुंचने का प्रयास करने के बारे में कुछ और जानकारी प्रदान कर सकते हैं? – xlembouras

उत्तर

4

आपको अपने मोंगोइड मॉडल में include Mongoid::MultiParameterAttributes शामिल करने की आवश्यकता है।

this GitHub issue on the problem देखें।

मैं इसे विशेष रूप से कहीं भी दस्तावेज नहीं मिल सका। ~

जो मुझे ठीक से पढ़ नहीं के लिए सिखाने जाएगा! This gem seems to be the solution though

+0

इस तरह से ऑटोक्राइटिक एक अच्छी बात है :) – Puce