Skip to content

Instantly share code, notes, and snippets.

@cmar
Created June 11, 2012 17:25
Show Gist options
  • Save cmar/2911433 to your computer and use it in GitHub Desktop.
Save cmar/2911433 to your computer and use it in GitHub Desktop.
irbrc to auto switch rails console
# 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