On Fri, 28 Jan 2005 02:25:39 +0900, Quintin Paulson <QPaulson / cucbc.com> wrote:
> Does anyone know of any documentation that shows how to extend a Model
> to allow it to use data from multiple tables?. Or does rails always need
> a single Model -> table relationship?..

I don't know of any specific documentation that deals with this issue,
but I've tackled the same issue in my own projects by simply using
associations and then mapping properties of the associated objects
onto the "master" object by overriding #method_missing on the master.

I.e.:

class Details < ActiveRecord::Base
  # some implementation...
end

class Data < ActiveRecord::Base
  # some implementation,,,
end

class Account < ActiveRecord::Base
  has_one :details, :class_name => 'Details'
  has_one :data, :class_name => 'Data'

  def method_missing(sym, *args, &block)
    begin
      super(*args, &block)
    rescue NoMethodError
      begin
        self.details.send(sym, *args, &block)
      rescue NoMethodError
        self.data.send(sym, *args, &block)
      end
    end
  end
end

Of course, this probably isn't the most elegant way of solving the
problem, but it may get you started on some other ideas for approching
the pattern.

-- 
Regards,
John Wilger

-----------
Alice came to a fork in the road. "Which road do I take?" she asked.
"Where do you want to go?" responded the Cheshire cat.
"I don't know," Alice answered.
"Then," said the cat, "it doesn't matter."
- Lewis Carrol, Alice in Wonderland