Czy istnieje sposób na przesłonięcie setera lub gettera dla modelu w Mongoid? Coś takiego:Zastępowanie ustawiających i pobierających modelu Mongoid'a
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
gdzie metoda name
może zostać nadpisana bez użycia wirtualnych pól?
związane: http://stackoverflow.com/questions/6699503/mongoid-custom-setters-getters-and-super – marcgg