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
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to