Created
May 31, 2013 13:37
-
-
Save dan1d/5685026 to your computer and use it in GitHub Desktop.
ActiveRecord without rails.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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