-
-
Save advorak/4398014 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NoMethodError in OrderitemsController#create | |
undefined method `stringify_keys' for #<Order:0x2c630a0> | |
Application Trace | Framework Trace | Full Trace | |
app/controllers/orderitems_controller.rb:11:in `create' | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Order < ActiveRecord::Base | |
attr_accessible :id, :title, :current_order, :customer_id, :final_pdf_created, :order_sent_at | |
## ASSOCIATIONS | |
has_many :orderitems | |
has_many :products, :through => :orderitems | |
belongs_to :customer | |
## METHODS | |
def self.defaultBoM(customer) | |
defaultBoM = customer.orders.new() | |
#defaultBoM.id = 0 | |
defaultBoM.title = "No title" | |
defaultBoM.current_order = 1 | |
defaultBoM.final_pdf_created = 0 | |
defaultBoM.created_at = defaultBoM.updated_at = DateTime.now() | |
defaultBoM | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create | |
customer = Customer.find(session[:customer_id]) if session[:customer_id] | |
if customer | |
#If order ID = 0 --> This has to be a new order, it hasn't been made yet | |
if params[:order_id] # params[:order_id] will return nil if the value doesn't exist in the submitted form... | |
#Get the default order | |
order = Order.defaultBoM(customer) | |
#order.id = nil # order.id will default to nil with a new record | |
#Create it | |
#order = Order.create(order) | |
order.save # this saves the order, which is contained within the order object | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment