rails初心者です
if文の条件分岐の仕方が分かりません
もっと具体的にいうと
課金済みorまだ課金していない で条件を分岐したいです
productsコントローラーのpurchaseアクションを動かしたことがある場合という感じで条件分岐を書きたいのですが、
その場合はどう書けばいいのでしょうか
<% if @current_user %>みたいな形ではどう考えても書けないですよね
拙い質問ですみません、お力貸していただけると嬉しいです
products/controller.rb class ProductsController < ApplicationController def index end def purchase Payjp.api_key = ENV["PAYJP_SECRET_KEY"] Payjp::Charge.create( :amount => 9800, :card => params['payjp-token'], :currency => 'jpy' ) end end
products/purchase.html.erb <div class="thanks"> <h6>支払いが完了しました。</h6> </div>
回答1件
あなたの回答
tips
プレビュー