Rails'' ActiveRecord objects share the db connection of the ARec object
from which they inherit. Normally, it''s ActiveRecord::Base and all
the ARec classes share the same connection. You can take advantage of
this to accomplish what you''re wanting to do...
class CompanyConnection < ActiveRecord::Base
self.abstract_class = true
establish_connection "company_#{RAILS_ENV}".to_sym
end
The class above will allow you to define three new db connections in
database.yml called company_development, company_test, and
company_production where you can define the connection to your
company''s db. Then, you can create classes that inherit from *this*
class that access your company DB (by default the others will still
refer to your db... or the ones defined by development, test, and
production in database.yml).
With the examples above...
class Tags < ActiveRecord::Base
...
end
class Cities < CompanyConnection
...
end
On Mar 3, 2:17 pm, Remco Swoany
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> Hi,
>
> i build my own rails-app, with "my" (own)database for a new
website. My
> company has a big central database (also mysql> same server > cluster
>
> but no rails-app) with some interesting content i want to use...customer
> reviews, faq, country/city-descriptions ect.
>
> How can i use this data in my app?
>
> Some requirements
>
> I want to load the cities-data from the central database in my rails-app
> and then use Acts As Taggable to do some tagging on the cities.
>
> Grtz
>
> remco
> --
> Posted viahttp://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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---