[updating question to clarify]
Can I create a model in Rails 3/3.1 and make ActiveRecord automatically use/append some joins I configured to that model?
Ex:
Use code like this:
class Component < ActiveRecord::Base
def self.base_query
joins("join t05 on d04.t05_ukey = t05.ukey left join d03 on d04.d03_ukey = d03.ukey left join d16 on d04.d16_ukey = d16.ukey")
end
end
Component.first # under the hood is doing Component.base_query.first
Component.where(...) # under the hood is doing Component.base_query.where
But ActiveRecord calls the method base_query under the hood without the need to explicitly call it. Just to make it more Rails-like.
Any ideas?