Kim wrote:
> To clarify:
> Some of the data for my rails app is stored in a non-rails DB table. I
> need to query this other database and then show the data in the rails
> app.

I can only tell you what I did when I needed to do this. I did NOT use 
find_by
_sql, I actually set up ActiveRecord classes for each table in the 'non 
rails DB'.  You can actually specify everything you need in ActiveRecord 
to over-ride rails conventions.  I did have several of these tables in 
the same 'non-rails' DB, so they DID have a common abstract superclass 
with a connection.

Here's the code, actually why copy and paste when I can link you to svn.

An AR model for a particular table, as you can see you can even use AR 
associations (to other tables within the same db! Trying to make 
associations cross-db tends not to work): 
http://umlaut.rubyforge.org/svn/trunk/app/models/sfx_db/object.rb

And the superclass that pretty much just establishes the connection 
(also note it uses an AR feature to make everything read-only, cause 
that's what I wanted in this case): 
http://umlaut.rubyforge.org/svn/trunk/app/models/sfx_db/sfx_db_base.rb

Once I set that up, I can and do use ordinary AR stuff with those 
models, no need for find_by_sql and such.



-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to