Skip to content

Instantly share code, notes, and snippets.

@ojiry
Created March 27, 2012 06:24
Show Gist options
  • Save ojiry/2213286 to your computer and use it in GitHub Desktop.
Save ojiry/2213286 to your computer and use it in GitHub Desktop.
# generate model
$ rails g model team name
$ rails g model user name age:integer team:references
$ rake db:migrate
$ sed -n '14,32p' db/schema.rb
ActiveRecord::Schema.define(:version => 20120327062610) do
create_table "teams", :force => true do |t|
t.string "name"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "users", :force => true do |t|
t.string "name"
t.integer "age"
t.integer "team_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "users", ["team_id"], :name => "index_users_on_team_id"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment