Created
January 8, 2014 09:39
-
-
Save ttanimichi/8314168 to your computer and use it in GitHub Desktop.
ActiveRecordを単体で使うサンプルコード
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" => "./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