要检查是否buyer.save
会失败,我使用buyer.valid?
:
def create
@buyer = Buyer.new(params[:buyer])
if @buyer.valid?
my_update_database_method
@buyer.save
else
...
end
end
我如何检查是否update_attributes
会失败?
def update
@buyer = Buyer.find(params[:id])
if <what should be here?>
my_update_database_method
@buyer.update_attributes(params[:buyer])
else
...
end
end