Single table inheritance strangeness

Posted by jacqui maher on April 29, 2008 at 10:19 PM

I suppose “special” is a word for this behavior. I would have expected a constraint used in find_by_id to also be used in find. Right.


>> Asset.find_by_id(params[:id])
# => nil

log: Asset Load (0.009816) SELECT * FROM assets WHERE (assets.`id` = ‘8515’) AND ( (assets.`class_name` = ‘Asset’ ) ) LIMIT 1

>> Asset.find(params[:id])
# => #“IdamAsset”, “updated_date”=>”2008-04-14 20:49:58”, “restrictions”=>nil, “idam_iud”=>”19013896”, “name”=>”6da9.jpg”, “hide”=>”0”, “is_pending”=>”0”, “is_administrative”=>”0”, “created_date”=>”2008-04-14 20:49:58”, “security_level”=>”1”, “media_type_id”=>”10”, “id”=>”8515”, “description”=>”“, “filename”=>”6da9.jpg”, “last_synced_at”=>nil, “uploaded_by_id”=>”448”}>

log: BaseAsset Load (0.000528) SELECT * FROM assets WHERE (assets.`id` = 8515)

Comments: 0 (view/add your own) Tags: rails, sti