Created
July 16, 2012 05:11
-
-
Save mockdeep/3120713 to your computer and use it in GitHub Desktop.
Active Record example 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' | |
ActiveRecord::Base.establish_connection( | |
:adapter => 'sqlite3', | |
:database => 'database') | |
ActiveRecord::Base.connection.execute <<-SQL | |
CREATE TABLE IF NOT EXISTS users ( | |
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, | |
name VARCHAR | |
); | |
SQL | |
class User < ActiveRecord::Base | |
end | |
u = User.new | |
u.name = 'blah' | |
u.save | |
puts User.first.name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment