ActiveMerchant购买功能轨道3.2.5质量分配

时间:2012-06-11 17:48:22

标签: ruby-on-rails activemerchant mass-assignment

我使用的是Rails 3.2.5。继Ryan Bates教程之后。

http://railscasts.com/episodes/145-integrating-active-merchant。我的order.rb有这个功能

  def purchase
    response = GATEWAY.purchase(price_in_cents, credit_card, purchase_options)
    transactions.create!(:action => "purchase", :amount => price_in_cents, :response => response)
    cart.update_attribute(:purchased_at, Time.now) if response.success?
    response.success?
  end

由于rails 3.2.5使用MassAssignmentSecurity.I会收到以下错误。

Can't mass-assign protected attributes: action, amount, response

我尝试将它们添加到attr_accessible列表但没有运气。如何将它们添加到列表中或至少覆盖它们?

1 个答案:

答案 0 :(得分:1)

请查看上一个主题:"WARNING: Can't mass-assign protected attributes"

我相信它会对你有帮助......