Use multiple databases in rails.


/ Published in: Ruby
Save to your folder(s)



Copy this code and paste it in your HTML
  1. class RegularModel < ActiveRecord::Base
  2. end
  3.  
  4.  
  5. class MyModel < ActiveRecord::Base
  6. establish_connection "another_db"
  7. end
  8.  
  9. # these then use the following, located in database.yml
  10. development:
  11. adapter: mysql
  12. database: firstdb
  13. pool: 5
  14. timeout: 5000
  15.  
  16. another_db:
  17. adapter: mysql
  18. database: second_db_table
  19. pool: 5
  20. timeoute: 5000

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.