0
屬性我收到此錯誤1個錯誤的多參數的分配從日期
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>
需要你的表單代碼 – jbmeerkat 2012-07-10 21:53:13
我們能否看到你的購物車型號? – Andrei 2012-07-12 14:27:00
我們是否也可以看到您的form_for代碼?爲什麼您的訂單模型沒有「belongs_to:cart」? – Andrei 2012-07-13 02:41:45