I was doing the following at the console to figure out why the created at attribute is not working.
I found out the following:
sr = StockReceiving.find :first
=> #<StockReceiving:0x3651ce4 @attributes={“discount”=>“0”, “modified_at”=>nil,
“created_by”=>“admin”, “purchase_order_id”=>“14”, “supplier_invoice”=>“dfgfdg”,
“warehouse_id”=>“2”, “id”=>“11”, “modified_by”=>nil, “supplier_id”=>“1”, "create
d_at"=>“2006-11-11 18:11:17”}>
sr
=> #<StockReceiving:0x3651ce4 @attributes={“discount”=>“0”, “modified_at”=>nil,
“created_by”=>“admin”, “purchase_order_id”=>“14”, “supplier_invoice”=>“dfgfdg”,
“warehouse_id”=>“2”, “id”=>“11”, “modified_by”=>nil, “supplier_id”=>“1”, "create
d_at"=>“2006-11-11 18:11:17”}>
sr.attributes
=> {“discount”=>0.0, “modified_at”=>nil, “purchase_order_id”=>14, “created_by”=>
“admin”, “supplier_invoice”=>“dfgfdg”, “warehouse_id”=>2, “id”=>11, "modified_by
"=>nil, “supplier_id”=>1, “created_at”=>nil}
When I show all the attributes of the object, it does not have a created_at attribute. I would like to know
what’s goin on. Here is the model:
class StockReceiving < ActiveRecord::Base
has_many :details , :class_name => ‘StockReceivingDetail’
def before_create
self.warehouse_id = ‘2’
self.created_by = ‘admin’
end
def before_update
self.modified_by = ‘admin’
self.modified_at = Date.now
end
end
Thank you in advance.
Junrey