Created
          June 11, 2012 17:25 
        
      - 
      
 - 
        
Save cmar/2911433 to your computer and use it in GitHub Desktop.  
    irbrc to auto switch rails console
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # store_works Apartment Switching | |
| if defined? Rails | |
| if defined? Apartment::Database | |
| def switch(store) | |
| Apartment::Database.switch(store) | |
| ENV['INTERNAL_SUBDOMAIN'] = store | |
| puts "=> Switching to #{store}" | |
| end | |
| class << self | |
| %w(store1 store2 test-store1 test-store2).each do |method_name| | |
| define_method(method_name) { switch(method_name) } | |
| end | |
| end | |
| store1 | |
| end | |
| end | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment