インライン エラーを使用したいので、Formtasticを使用して支払いフォームを作成しようとしています。請求を処理するために ActiveMerchant を使用しています。私は次のフォームを持っています:
<%= 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 %>
そして、これは私のPayment
モデルにあるものです:
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
無効なクレジット カードを送信すると、無効であると判断されますが、formtastic からインライン エラーが発生しません。
ここに欠けている単純なものがあると思いますが、何がわからないのですか。
これはRails 3にあります。