I'm trying to use Formtastic to create a payment form, since I'd like to use the inline errors. I'm using ActiveMerchant to handle the billing. I have the following form:
<%= semantic_form_for @payment do %>
<%= form.inputs do %>
<%= form.input :email, :label => "Email Address" %>
<%= form.semantic_fields_for :credit_card_attributes do |cc| %>
<%= cc.input :number, :label => "Credit Card Number" %>
<%= cc.input :first_name, :label => "First Name" %>
<%= cc.input :last_name, :label => "Last Name" %>
<%= cc.input :month, :label => "Expiration Month" %>
<%= cc.input :year, :label => "Expiration Year" %>
<%= cc.input :verification_value, :label => "Verification Code" %>
<% end %>
<% end %>
<% end %>
And this is what's in my Payment
model:
class Payment < ActiveRecord::Base
validates_associated :credit_card, :on => :create
def credit_card_attributes=(attrs)
@credit_card = ActiveMerchant::Billing::CreditCard.new(attrs)
end
def credit_card
@credit_card
end
end
When I submit an invalid credit card, it figures out that it's invalid, but I don't get any of the inline errors from formtastic.
I figure there's probably something simple I'm missing here, I'm just not sure what.
This is on Rails 3.