द्वारा क्वैरी मैं इस तरह एक मॉडल है:रेल + MongoID विशेषता
class Lesson
include Mongoid::Document
field :title, :type => String
field :category, :type => String
field :price, :type => Float
field :description, :type => String
field :user_id, :type => String
validates_presence_of :title
validates_presence_of :category
validates_presence_of :price
validates_presence_of :user_id
attr_accessible :title, :category, :description, :price
end
और मैं इस तरह क्वेरी करने के लिए कोशिश कर रहा हूँ:
@lessons_by_user = Lesson.find_by_user_id current_user.id
और मैं हो रही है:
पाठ के लिएअपरिभाषित विधि `find_by_user_id ': कक्षा
मैं MongoID में एक विशिष्ट विशेषता से कैसे पूछ सकता हूं?
मुझे पता है कि इस तरह से यह करने के लिए:
@lessons = Lesson.all(:conditions=>{:user_id=>current_user.id.to_s})
लेकिन अगर वहाँ एक शॉर्टकट है मैं सोच रहा हूँ ...
बहुत बढ़िया। जानना वास्तव में अच्छा है। –