Forum: Ruby on Rails easy before_update question (i hope)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Scott N. (Guest)
on 2008-11-10 11:02
(Received via mailing list)
in a before_update is there an easy way to check if a specific field
is being changed?

for example

def before_update
  unless current.email == new.email
    # do stuff
  end
end

obviously "current.email" and "new.email" are wrong. i am guessing one
will be "self.email", what would the other be?
Frederick C. (Guest)
on 2008-11-10 12:08
(Received via mailing list)
On 10 Nov 2008, at 09:02, scott wrote:

> end
>
> obviously "current.email" and "new.email" are wrong. i am guessing one
> will be "self.email", what would the other be?

from 2.1 onwards you'll get an email_changed? method for free.

Fred
This topic is locked and can not be replied to.