I´m looking for a way to do simple ruby code without rails. I´m coming from PHP world, and sometimes, I just build a page with a Mysql connection, run a query and show resul
This should do the work:
require 'rubygems'
gem 'activerecord'; require 'active_record'
class User < ActiveRecord::Base
end
ActiveRecord::Base.establish_connection(
:adapter => 'mysql',
:database => 'test',
:user => 'user',
:password => 'pass'
)
User.all.each do |u|
puts "#{u.name} - #{u.age}
"
end
Before running it you need to install activerecord:
gem install activerecord