Skip to content

Instantly share code, notes, and snippets.

@dan1d
Created May 31, 2013 13:37
Show Gist options
  • Save dan1d/5685026 to your computer and use it in GitHub Desktop.
Save dan1d/5685026 to your computer and use it in GitHub Desktop.
ActiveRecord without rails.
require "active_record"
require "sqlite3"
ActiveRecord::Base.establish_connection(
:adapter => 'sqlite3',
:database => 'ejemplo',
:host => 'localhost')
ActiveRecord::Schema.define(:version => 0) do
create_table "categories", :force => true do |t|
t.string "name"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
end
class Category < ActiveRecord::Base
attr_accessible :name
end
cat = Category.create(name: 'Un nombre')
puts "Categoria nueva: #{cat.name}"
puts "Creado el dia: #{cat.created_at}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment