Guest User

Untitled

a guest
Jul 27th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. Open connection to mysql DB in the rake task
  2. ActiveRecord::Base.establish_connection(
  3. :adapter => "mysql2",
  4. :database => "foo",
  5. :user => "root",
  6. :password => "",
  7. )
  8.  
  9. class MyCustomClass < ActiveRecord::Base
  10. establish_connection(
  11. :adapter => "mysql2",
  12. :database => "foo",
  13. :user => "root",
  14. :password => "",
  15. )
  16. end
  17.  
  18. MyCustomClass.find(1)
  19.  
  20. client = Mysql2::Client.new(:host => "localhost", :username => "root", :database => "foobar", :password => "")
  21. users = client.query("SELECT * FROM users")
Add Comment
Please, Sign In to add comment