title: Changing ruby controller variable based on input from a view
body: <p>I am using stripe to collect money for a website I am making. </p>
  
  <p>Here is my view:</p>
  
  <pre><code>%script.stripe-button{"data-amount" =&gt; "10000", "data-description" =&gt; "A Generous Donation", "data-key" =&gt; Rails.configuration.stripe[:publishable_key], src: "https://checkout.stripe.com/v2/checkout.js"}
  %br
  %b Amount:
  %br
  %input
  %script.stripe-button{"data-amount" =&gt; "", "data-description" =&gt; "A Generous Donation", "data-key" =&gt; Rails.configuration.stripe[:publishable_key], src: "https://checkout.stripe.com/v2/checkout.js",  style:"padding-left: 30px;"}
  </code></pre>
  
  <p>Here is my controller:</p>
  
  <pre><code>def create
      # Amount in cents
      @amount = 500
  
      customer = Stripe::Customer.create(
        :email =&gt; 'example@stripe.com',
        :card  =&gt; params[:stripeToken]
      )
  
      charge = Stripe::Charge.create(
        :customer    =&gt; customer.id,
        :amount      =&gt; @amount,
        :description =&gt; 'Rails Stripe customer',
        :currency    =&gt; 'usd'
      )
  
    rescue Stripe::CardError =&gt; e
      flash[:error] = e.message
      redirect_to charges_path
    end
  </code></pre>
  
  <p>For my first button, I am trying to send the data-amount to the amount variable. For the second, I am trying to collect a value from the input box and set the @amount variable and the data-amount tag in the stripe-button to collect the payment. How do I do this?</p>