Skip to content

Instantly share code, notes, and snippets.

@ttanimichi
Created January 8, 2014 09:39
Show Gist options
  • Save ttanimichi/8314168 to your computer and use it in GitHub Desktop.
Save ttanimichi/8314168 to your computer and use it in GitHub Desktop.
ActiveRecordを単体で使うサンプルコード
require 'active_record'
ActiveRecord::Base.establish_connection(
"adapter" => "sqlite3",
"database" => "./data.sqlite")
class TestCreation < ActiveRecord::Migration
def up
create_table :entries do |t|
t.string :title
t.timestamps
end
create_table :somethigs do |t|
t3.string :title
t.timestamps
end
end
end
TestCreation.new.up
class Entry < ActiveRecord::Base
end
Entry.create(:title => "hogehoge")
tc = Entry.new(:title => "foobar")
tc.save
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment