Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- around_filter :hijack_db
- def hijack_db
- begin
- ActiveRecord::Base.connection = ActiveRecord::Base.establish_connection(
- :adapter => "mysql",
- :host => "localhost",
- :username => "root",
- :password => "",
- :database => @nejaka_ta_db
- )
- yield
- rescue Mysql::Error
- # DB NEEXISTUJE NEBO JE NEJAKY PROBLEM
- ensure
- # nakonec to vracime zpet
- ActiveRecord::Base.establish_connection( RAILS_ENV.to_sym )
- end
- end
Add Comment
Please, Sign In to add comment