# Form Not Displaying Errors

**URL:** <https://www.ruby-forum.com/t/form-not-displaying-errors/225996>\
**Category:** Rails\
**Created:** [March 11, 2008, 9:45pm UTC](https://www.ruby-forum.com/t/form-not-displaying-errors/225996 "2008-03-11T21:45:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![keaja](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/838e76/32.png) [@keaja](https://www.ruby-forum.com/u/keaja)\
**Post date:** [March 11, 2008, 9:45pm UTC](https://www.ruby-forum.com/t/form-not-displaying-errors/225996/1 "2008-03-11T21:45:18Z")

</div>

Not sure why but my form is not displaying errors. One of the first  
parts of my method is to check for errors and display them before  
processing the credit card. It just skips that part regardless of  
errors or not and tries to process the credit card.

def signup\_unlimited  
@user = User.new  
end

def signup\_unlimited\_create  
User.transaction do  
@user = User.new(params[:user])  
@user.account\_type = “Unlimited”  
@user.login = @user.email  
@number = params[:card\_number]  
@month = params[:card\_expiration\_month]  
@year = params[:card\_expiration\_year]  
@type = params[:card\_type]

```
  gateway = ActiveMerchant::Billing::BraintreeGateway.new({
      :login => 'btdemo',
      :password => 'btdemo123'
  })

  if @user.errors.empty?
    if @number != "" and @month != "" and @year != "" and @type !=

```

“”  
@card =  
ActiveMerchant::Billing::CreditCard.new(:first\_name =\>  
@user.first\_name,  
:last\_name =\> @user.last\_name,  
:number =\> params[:card\_number],  
:month =\> params[:card\_expiration\_month],  
:year =\> params[:card\_expiration\_year],  
:type =\> params[:card\_type])

```
        @amount = 430.50

        @options = { :store => true, :order_id => "1212451" }
        response = gateway.authorize(@amount, @card,

```

@options)

```
        if @card.id != nil
          self.current_user = @user
          @user.credit_card_id =

```

response.params[“customer\_vault\_id”]  
end

```
        if @user.credit_card_id != nil
          @user.save
          @invoice = Invoice.new(params[:invoice])
          @invoice.amount = "9.95"
          @invoice.due_date = Date.today + 30
          @invoice.generated_date = Date.today
          @invoice.status = "Due"
          @invoice.user_id = @user.id
          @invoice.save
          self.current_user = @user
          flash[:notice] = "Thanks for signing up"
          redirect_to :action => 'index'
        end

        if @user.credit_card_id == nil
          flash[:notice] = "Please verify your credit card

```

information below."  
render :action =\> ‘signup\_unlimited’  
end  
else  
flash[:notice] = “Please fill out all the necessary billing  
information.”  
render :action =\> ‘signup\_unlimited’  
end  
else  
flash[:notice] = “errors with your user form”  
render :action =\> ‘signup\_unlimited’  
end  
end  
end

Form is pretty standard, including the error\_messages part  
\<%= error\_messages\_for :user %\>  
\<%= image\_tag ‘signup\_header.jpg’ %\>

## For your unlimited account
\<% form\_for :user, :url =\> { :action =\> :signup\_unlimited\_create } do | f| %\>
