私はストライプ ジェムを使用しており、非常に基本的な設定に従ってカードをチャージしました。請求が正常に処理されたときに、データベースのフィールドを変更しようとしています。以下のコードは、データベースの :charge (ブール型) フィールドを 1 に更新していません。
処理が成功すると、ユーザーは create.html.erb にリダイレクトされますが、別のパスにリダイレクトする必要がありますが、その方法を見つけることができませんでした。
ありがとうスタック!
料金コントローラー:
class ChargesController < ApplicationController
def index
end
def new
end
def create
    @event = Event.find(session[:event_id])
    #Amount in cents
    @amount = 199
    customer = Stripe::Customer.create(
        :email => "user email",
        :card => params[:stripeToken]
    )
    charge = Stripe::Charge.create(
        :customer => customer.id,
        :amount => @amount,
        :description => 'description',
        :currency => 'usd'
    )
    @event[:charge] == 1
rescue Stripe::CardError => e
    flash[:error] = e.message
    redirect_to charges_path
end
end
New.html.erb:
<ul class="breadcrumb">
  <li><a href="#">Event Information</a></li>
  <li><a href="#">Image Upload</a></li>
  <li><a href="#">Verify Details</a></li>
  <li class="active">Pay</li>
</ul>
<%= form_tag charges_path do %>
<article>
    <label class="amount">
        <span>Amount: $1.99</span>
    </label>
</article>
<script src="https://checkout.stripe.com/v2/checkout.js" class="stripe-button"
        data-key="<%= Rails.configuration.stripe[:publishable_key] %>"
        data-description="description"
        data-amount="199"></script>
<% end %>
Create.html.erb
<h2>Thanks, you paid <strong>$1.99</strong>!</h2>