I have a code that once i create the order, it will automatically fill up information for the order items (because every order has many items) but i have the error uninitialized constant Order::OrderItem. How do i solve this?
Model
class Order < ActiveRecord::Base
# attr_accessible :title, :body
attr_accessible :amount, :currency
has_many :order_items
end
class OrderItems < ActiveRecord::Base
attr_accessible :items, :order_id, :quantity
belongs_to :order
end
Controller
def checkout
@order = Order.new # Create new order
@order.total = @shopping_cart.total
@order.sub_total = @shopping_cart.subtotal
@order.sales_tax = @shopping_cart.taxes
@shopping_cart.shopping_cart_items.each do |cart_item|
@orderitems = @order.order_items.build(items: cart_item.item.name, quantity: cart_item.quantity)
end
end