My brain is shutting down. I think I need sugar. Sorry for having to ask such a basic question but I’ve lost the ability to think for myself!
Please could someone tell me if I’m doing this the right way? Can I set a model’s attribute by assigning a value to a class attribute like so:
class MailBox < ApplicationRecord ... def reset_message_count self.message_count = 0 end end
My tests tell me it’s okay. But I’m doubting myself and can’t find a references that says it’s the way to do it.
Why does the above work and not the following?
class MailBox < ApplicationRecord ... def reset_message_count update_attribute(message_count: 0) end end