क्या मोंगोइड में एक मॉडल के लिए एक सेटर या गेटटर को ओवरराइड करने का कोई तरीका है? की तरह कुछ:एक मोंगोइड मॉडल के सेटर्स और गेटर्स को ओवरराइड करें
class Project
include Mongoid::Document
field :name, :type => String
field :num_users, type: Integer, default: 0
key :name
has_and_belongs_to_many :users, class_name: "User", inverse_of: :projects
# This will not work
def name=(projectname)
@name = projectname.capitalize
end
end
जहां name
विधि आभासी क्षेत्रों का उपयोग किए बिना ओवरराइट किया जा सकता?
संबंधित: http://stackoverflow.com/questions/6699503/mongoid-custom-setters-getters-and-super – marcgg