I have Rails code like:
def charge_card
return charge_on_house if house_account?
assign_order_number
if credit_card?
begin
save! #==>here
charge = Stripe::Charge.create(
amount: (total.to_f * 100).ceil,
currency: 'usd',
customer: customer.stripe_id,
card: payment_method,
description:"Saint Germain Order: #{self.number}"
)
self.update(
payment_status: 'paid'
)
self.finish!
rescue Stripe::StripeError => e
self.update(
admin_comments: e.message,
)
self.decline!
ensure
notify_user
end
end
self.save!
end
I want to skip validation on save! on line no 6 rather it is raising the error messages.
With save!
validations always run. If any of them fail ActiveRecord::RecordInvalid
gets raised.
Try
.save(validate: false)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With