To check if buyer.save
is going to fail I use buyer.valid?
:
def create
@buyer = Buyer.new(params[:buyer])
if @buyer.valid?
my_update_database_method
@buyer.save
else
...
end
end
How could I check if update_attributes
is going to fail ?
def update
@buyer = Buyer.find(params[:id])
if <what should be here?>
my_update_database_method
@buyer.update_attributes(params[:buyer])
else
...
end
end
my_update_database_method
before calling toupdate_attributes
, andmy_update_database_method
should be called only ifupdate_attributes
will succeed. – Owens