Advertisement
Guest User

Untitled

a guest
May 24th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. # whenever you need to do a custom query/function/sproc into another DB that is not development
  2. app = ActiveRecord::Base.establish_connection(
  3. adapter: "mysql",
  4. host: "localhost",
  5. username: "myuser",
  6. password: "mypass",
  7. database: "somedatabase"
  8. )
  9. # if you have already defined an entry in database.yml
  10. # -------------- READ THIS TOO ---------------------------------
  11. # use app = ActiveRecord::Base.establish_connection(:your_custom_db)
  12.  
  13. sql = <<-SQL
  14. select * FROM whatever_table( 'somestring', 2016 );
  15. SQL
  16. app.connection.execute(sql)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement