I have an active record model and want a way to have an attribute that gets passed in on creation but isn’t a row in the database. Basically, it will determine whether a logging record gets created in another table.
I was thinking something like this:
Item.create!({:header_id => 17, :header => 'here is my value', :position => 13.125, :created_from_inventory => true })
The :created_from_inventory doesn’t exist in db but will be used in a callback.
Any ideas on how to do this?
thx
Try adding this to the item model
It will add a non db attribute to your model. It will exist as long as the instance exists. once the instance goes out of scope it will be lost.