Guest User

Untitled

a guest
Aug 14th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. How to show sql result on server console
  2. ActiveRecord::Base.connection.execute("select count(*) from cars;")
  3.  
  4. rslt = ActiveRecord::Base.connection.execute("select count(*) from cars;")
  5. p rslt
  6.  
  7. rslt = ActiveRecord::Base.connection.execute("select count(*) from cars;")
  8. rslt.each {|mysql_result| puts mysql_result}
  9.  
  10. class HomeController < ActionController::Base
  11. def index
  12. rslt = ActiveRecord::Base.connection.execute("select count(*) from cars;")
  13. logger.info "#{rslt}"
  14. end
  15. end
Add Comment
Please, Sign In to add comment