Execute_sql Oct 25th, 2017 9:51 pm ref https://stackoverflow.com/questions/15408285/rails-3-execute-custom-sql-query-without-a-model 1 2 3 4 5 6 7 ActiveRecord::Base.establish_connection({adapter: 'mysql2', encoding: 'utf8', database: DB, username: USER,password: PASSWD}) sql = "SELECT * from users" @result = ActiveRecord::Base.connection.execute(sql); @result.each do |r| puts r["name"] end