I have a ton of models (>50) and each share a same set associations.
Like so.
class Foo < ActiveRecord::Base
belongs_to :created_by_user, foreign_key: :created_by, class_name: 'User'
belongs_to :updated_by_user, foreign_key: :updated_by, class_name: 'User'
belongs_to :deleted_by_user, foreign_key: :deleted_by, class_name: 'User'
# other associations
end
Since the relation is exactly same for all my models (we need to keep track which user changed a record), anyway to to include these associations with one call?
Something like this? (this doesn't work)
Basically I would like something like:
class Foo < ActiveRecord::Base
include DefaultUserAssociation
# other associations
end