我收到此错误
1 error(s) on assignment of multiparameter attributes
我很确定它来自 date_selector。
这是我的模型
class Order < ActiveRecord::Base
attr_accessor :card_type, :card_number, :card_verification,
:card_expires_on # I do not have these fields in my database
attr_accessible :cart_id, :card_expires_on, :card_type, :first_name,
:ip_address, :last_name,:card_number, :card_verification, :zip, :address,
:state, :city
def credit_card
@credit_card ||= ActiveMerchant::Billing::CreditCard.new(
:brand => card_type,
:number => card_number,
:verification_value => card_verification,
:month => card_expires_on.month,
:year => card_expires_on.year,
:first_name => first_name,
:last_name => last_name
)
end
end
以及涉及的控制器部分
def create
@user = current_user
@cart = current_cart
@order = @cart.build_order(params[:order]) # here is where the error is
@order.user_id = @user.id
@order.ip_address = request.remote_ip
...
end
这是购物车模型
class Cart < ActiveRecord::Base
has_many :line_items, :dependent => :destroy
has_one :order
belongs_to :user
def add_product(product_id)
current_item = line_items.find_by_product_id(product_id)
if current_item
current_item.quantity += 1
else
current_item = line_items.build(:product_id => product_id)
end
current_item
end
def total_price
line_items.to_a.sum { |item| item.total_price}
end
def total_price_in_cents
return Integer(total_price * 100)
end
end
下面是 order.rb 附带的订单...再次感谢您的帮助!!!
<div class="field">
<%= f.label :first_name %><br />
<%= f.text_field :first_name %>
</div>
<div class="field">
<%= f.label :last_name %><br />
<%= f.text_field :last_name %>
</div>
<div class="field">
<%= f.label :address %>
<%= f.text_field :address %>
</div>
<div class="field">
<%= f.label :city %>
<%= f.text_field :city %>
</div>
<div class="field">
<%= f.label :state %>
<%= f.select :state, @order.us_states %>
</div>
<div class="field">
<%= f.label :zip %>
<%= f.text_field :zip %>
</div>
<div class ="field">
<%= f.label :card_type %> <br />
<%= f.select :card_type, [["Visa", "visa"], ["MasterCard", "master"], ["Discover", "discover"], ["American Express", "american_express"]] %>
</div>
<div class="field">
<%= f.label :card_number %><br />
<%= f.text_field :card_number %>
</div>
<div class="field">ry
<%= f.label :card_verification, "Card Verification (CVV)" %><br />
<%= f.text_field :card_verification %>
</div>
<div class="field">
<%= f.label :card_expires_on %><br />
<%= f.date_select :card_expires_on, :discard_day => true, :start_year => Date.today.year, :end_year => (Date.today.year+10), :add_month_numbers => true %>
</div>
<div class="actions">
<%= f.submit %>
</div>