Hello By default, RubyOnRails let you have 3 databases, development, test and production. Can we add more databases in this file? Is there any limitation? Example --------------------------------------- START % cat config/database.yml development: adapter: mysql database: rails_development host: localhost username: davis password: hogehero test: adapter: mysql database: rails_test host: localhost username: davis password: hogehero production: adapter: mysql database: rails_production host: localhost username: davis password: hogehero production1: adapter: mysql database: rails_production1 host: localhost username: davis password: hogehero production2: adapter: mysql database: rails_production2 host: localhost username: davis password: hogehero --------------------------------------- END Have anyone added more databases? Please let me know how did it go. Thank you! -- 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-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 -~----------~----~----~----~------~----~------~--~---
Eriko Uchi wrote:> By default, RubyOnRails let you have 3 databases, development, test and > production. > Can we add more databases in this file? Is there any limitation?Can we change RAILS_ENV to ''beatlemania'', add a matching item to the config/environment folder and the database.yml file? Under Rails, I suspect the answer is yes, because Convention over Configuration allows the system to minimize all its configuration systems. But I suspect nobody ever needed to do this. You are not asking for a new concept, beyond the natural trinity of test, develop, and produce. You are just asking for alternate databases. Toke some eRB:> production: > adapter: mysql > database: rails_productiondatabase: <%= ENV[''RAILS_DB''] %> Now set that environmental variable (in the environment, or in config/boot.rb if you can''t access the environment). -- Phlip http://www.oreilly.com/catalog/9780596510657/ ^ assert_xpath http://tinyurl.com/yrc77g <-- assert_latest Model --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
dblack-TKXtfPMJ4Ozk1uMJSBkQmQ@public.gmane.org
2007-Aug-16 14:51 UTC
Re: Can we put any number of databases in YML file?
Hi -- On Thu, 16 Aug 2007, Eriko Uchi wrote:> > Hello > > By default, RubyOnRails let you have 3 databases, development, test and > production. > Can we add more databases in this file? Is there any limitation?What you''re really doing is creating (or implying) new environments. If you add a file production1.rb to config/environments (look at the ones there for examples) and add your production1 stanza to database.yml, you can then run in a new environment: ./script/server -e production1 David -- * Books: RAILS ROUTING (new! http://www.awprofessional.com/title/0321509242) RUBY FOR RAILS (http://www.manning.com/black) * Ruby/Rails training & consulting: Ruby Power and Light, LLC (http://www.rubypal.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 -~----------~----~----~----~------~----~------~--~---
Another way of using database.yml (separate from environments) is to store separate connections that may only be used by a few models in an application. You can specify all of the database details in database.yml, then connect to them in your model i.e. some_other_db: adapter: mysql database: anotherdatabase username: dbuser host: someotherhost Then in the models that will use this connection: establish_connection :some_other_db I have used this a few times and it works well. It has the benefit of keeping all db connection information in one place rather than specifying it directly in establish_connection. (See Agile page 293) dblack-TKXtfPMJ4Ozk1uMJSBkQmQ@public.gmane.org wrote:> Hi -- > > On Thu, 16 Aug 2007, Eriko Uchi wrote: > > >> Hello >> >> By default, RubyOnRails let you have 3 databases, development, test and >> production. >> Can we add more databases in this file? Is there any limitation? >> > > What you''re really doing is creating (or implying) new environments. > If you add a file production1.rb to config/environments (look at the > ones there for examples) and add your production1 stanza to > database.yml, you can then run in a new environment: > > ./script/server -e production1 > > > David > >-- Sincerely, William Pratt http://www.billpratt.net billp-YbheRAKfYF4eIZ0/mPfg9Q@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---