title: Rails mailer view template pass value send by a form
body: <p>Its my first attempt to use the rails mailer to send email. I however is able to send plain emails but when I tried to pass the logged in user (current_user) name and params values send by the form I am getting the error. Undefined method 'params'.</p>
  
  <p>payment_mailer.rb</p>
  
  <pre><code>class PaymentMailer &lt; ApplicationMailer
      def success(user)
          mail(to: "#{user.first_name} #{user.last_name} &lt;#{user.email}&gt;", subject: "Payment Successful")
      end
  end
  </code></pre>
  
  <p>success.html.erb</p>
  
  <pre><code>&lt;div class = "col-sm-12"&gt;
            &lt;h1&gt;Payment Successful&lt;/h1&gt;
            &lt;p&gt;Dear &lt;%= user.first_name %&gt;, Thank you for being a part of our system&lt;br&gt;
              Your invoice (#&lt;%= params[:id] %&gt;) has been generated.
            &lt;/p&gt;
          &lt;/div&gt;
          &lt;div class = "clearfix"&gt;&lt;/div&gt;
          &lt;div class = "col-sm-6"&gt;
            &lt;table class = "table"&gt;
              &lt;thead&gt;
                &lt;tr&gt;
                  &lt;th&gt;Paid Ammount&lt;/th&gt;
                  &lt;th&gt;Card Transaction Fee (2.9% + 0.30)&lt;/th&gt;
                  &lt;th&gt;Credited Ammount&lt;/th&gt;
                &lt;/tr&gt;
              &lt;/thead&gt;
              &lt;tbody&gt;
                &lt;tr&gt;
                  &lt;td&gt;&amp;euro;&lt;%= params[:amount] %&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;/td&gt;
                &lt;/tr&gt;
              &lt;/tbody&gt;
              &lt;h3&gt;Total credited amount in your Account is: &lt;/h3&gt;
            &lt;/table&gt;
          &lt;/div&gt;
          &lt;div class = "clearfix"&gt;&lt;/div&gt;
        &lt;/div&gt;
  </code></pre>
  
  <p>payment_controller.rb</p>
  
  <pre><code>amount = params[:amount]
  @user = current_user
  netamt =  (amount.to_f - ((amount.to_f*2.9)/100 + 0.30))
  payment = @user.payments.create(:amount =&gt; netamt, :method =&gt; "Card", :txn_code =&gt; params[:stripeToken])
  @user.update_attribute(:balance, @user.balance+netamt)
  PaymentMailer.success(current_user).deliver_now
  </code></pre>
  
  <p>Please guide me.</p>