ruby on rails - NoMethodError in OrdersController#create -
I'm building a simple shopping app and using Ryan Bats's "# 145 integrated active businessman" Checkout process I am using the guidance.
Order Model:
class order & lt; ActiveRecord :: Base has_many: order_products has_many: Product, via: order_products attr_accessor: CARD_NUMBER ,: security_code,: card_expires_ondef CREDIT_CARD @credit_card || = ActiveMerchant :: Billing :: CreditCard.new (: first_name = & gt; first_name ,: last_name = & gt; last_name, CARD_NUMBER = & gt; CARD_NUMBER: verification_value = & gt; security_code ,: month = & gt; card_expires_on {Month}: years => card_expires_on {year}) end DEF self.purchase (basket) response = GATEWAY .purchase (Product.total_basket_price (basket), CREDIT_CARD) end end
Orders_controller:
Create DEF @order = Order.new basket.each | ITEM_ID | @ Order.order_products.build (Product: product.find (item_id)) End if @ order.save! If the @ order.purchase render "show" and submit 'new' to any other end, 'new' end end
product model:
Def self.total_basket_price (basket) where (id: basket.to_a) .sum (: price) * 100 end
When I click submit, I get the following error message :
The text "itemprop =" text ">
purchase
is a class record, but you can call it command . Apart from this, logic is required for this method, but you try to call them without it.
Comments
Post a Comment