ruby on rails - Call before_update if an attribute is filled -
what way call before_update trigger if particular attribute filled?
here part of code:
before_update { self.gravatar = gravatar.downcase } validates :gravatar, :on => :update, length: { maximum: 128 }, format: { with: valid_gravatar_regex }, allow_blank: true
indeed want call downcase function on attribute if 1 filled in edit form.
i have following error:
undefined method `downcase' nil:nilclass
which logical.
like ? before_update { self.gravatar = gravatar.downcase if gravatar.present? }
Comments
Post a Comment