Home>

How to separate methods
card = Card.find_by (user_id: current_user.id) is also used in other actions, so I was told to divide it into methods, but I don't know how to do it.
Please professor

class PurchaseController  10000,
    : customer =>card.customer_id,
    : currency =>'jpy',
  )
  redirect_to action: 'done'
  end
  def done
    card = current_user.cards.first
    redirect_to controller: "card", action: "new" if card.blank?
   end
 end