I have a order object, which have a create method like this :
def create
@order = Order.new(params[:order])
# @order.status_id = "1"
respond_to do |format|
if @order.save
flash[:notice] = 'Order was successfully created.'
format.html { redirect_to(@order) }
format.xml { render :xml => @order, :status => :created, :location => @order }
else
format.html { render :action => "new" }
format.xml { render :xml => @order.errors, :status => :unprocessable_entity }
end
end
end
I want to set the @order status_id to "1", so I have the
@order.status_id = "1"
But this code is not work, after I uncomment it, it still can't save "1" in the status_id in db, but other attribute can successfully store.
order.rb
class Order < ActiveRecord::Base
has_many :order_items
belongs_to :status
end