Validate if different?


#1

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


#2

you can simple compare posted hash with the database record, i.e.
something
like that

if (Model.find(id) == params[:model]) …


#3

Thanks, Emin. Yes, that would work, but I thought I read someplace
onetime
there was a built-in method that woul do this.

Steve


#4

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/ActiveRecord/Acts/Versioned/ActMethods.html#M000010


#5

Right on. Thanks Emin.