Using "vanilla model" for find_by_sl()

I have several hairy SQL queries that join and select columns from
multiple tables. The standard AR pattern:

MyModel.find_by_sql(hairy_sql_query)

has rules about which attributes in MyModel are preserved and which
attributes are added as a result of the query. The problem is that the
dynamic finders and accessor methods from MyModel can intermingle and
sometimes shadow attributes returned as a result of the query.

It seems you could create a vanilla model:

class Vanilla < ActiveRecord::Base
end

whose sole job is to act as a container for find_by_sql() queries, e.g.:

Vanilla.find_by_sql(hairy_sql_query)

Can you think of any flaws to this approach (before I go and create a
new git branch :)?

  • ff