KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Is there a way to override a setter or getter for a model in Mongoid? Something like: 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 where the name method can be overwritten without using virtual fields?
Tags (comma-separated)
Save Edits
Cancel