Forum: Ruby on Rails validate if different?

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.
E98de78bb42013c488fe8aa9d77d2cb1?d=identicon&s=25 Steve Odom (Guest)
on 2006-03-24 14:07
(Received via mailing list)
Hi, I seem to remember seeing the equivalent of saving only if all
attributes are different. I can't seem to find that now in the API or
the
agile book.

I'm using the acts_as_versioned and only want to save if the input is
different.

Thanks,

Steve
http://www.smarkets.net
7cda78d70ab775710f6fa24e0a5b68db?d=identicon&s=25 Emin Hasanov (Guest)
on 2006-03-24 20:39
(Received via mailing list)
you can simple compare posted hash with the database record, i.e.
something
like that

if (Model.find(id) == params[:model]) ...
E98de78bb42013c488fe8aa9d77d2cb1?d=identicon&s=25 Steve Odom (Guest)
on 2006-03-24 20:42
(Received via mailing list)
Thanks, Emin. Yes, that would work, but I thought I read someplace
onetime
there was a built-in method that woul do this.

Steve
7cda78d70ab775710f6fa24e0a5b68db?d=identicon&s=25 Emin Hasanov (Guest)
on 2006-03-24 20:50
(Received via mailing list)
never used acts_as_versioned, but quick look to api shows "changed?"
method
which should be what you are looking for

http://ar-versioned.rubyforge.org/classes/ActiveRe...
E98de78bb42013c488fe8aa9d77d2cb1?d=identicon&s=25 Steve Odom (Guest)
on 2006-03-24 20:59
(Received via mailing list)
Right on. Thanks Emin.
This topic is locked and can not be replied to.