From ff5ec335606ec0953db867047be3228c4f111af5 Mon Sep 17 00:00:00 2001 From: Michael Hartl Date: Sat, 21 Aug 2010 13:47:33 -0700 Subject: [PATCH] Created a User model --- Gemfile | 1 + Gemfile.lock | 2 ++ app/models/user.rb | 15 +++++++++++++++ db/migrate/20100821203213_create_users.rb | 14 ++++++++++++++ db/schema.rb | 22 ++++++++++++++++++++++ spec/models/user_spec.rb | 5 +++++ 6 files changed, 59 insertions(+) create mode 100644 app/models/user.rb create mode 100644 db/migrate/20100821203213_create_users.rb create mode 100644 db/schema.rb create mode 100644 spec/models/user_spec.rb diff --git a/Gemfile b/Gemfile index c2a1628..9761477 100644 --- a/Gemfile +++ b/Gemfile @@ -6,6 +6,7 @@ gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3' group :development do gem 'rspec-rails', '2.0.0.beta.18' + gem 'annotate-models' end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index ec40776..8f75b40 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -28,6 +28,7 @@ GEM activemodel (= 3.0.0.rc) activesupport (= 3.0.0.rc) activesupport (3.0.0.rc) + annotate-models (1.0.4) arel (0.4.0) activesupport (>= 3.0.0.beta) builder (2.1.2) @@ -87,6 +88,7 @@ PLATFORMS ruby DEPENDENCIES + annotate-models rails (= 3.0.0.rc) rspec (= 2.0.0.beta.18) rspec-rails (= 2.0.0.beta.18) diff --git a/app/models/user.rb b/app/models/user.rb new file mode 100644 index 0000000..6c40003 --- /dev/null +++ b/app/models/user.rb @@ -0,0 +1,15 @@ +# == Schema Information +# Schema version: 20100821203213 +# +# Table name: users +# +# id :integer not null, primary key +# name :string(255) +# email :string(255) +# created_at :datetime +# updated_at :datetime +# + +class User < ActiveRecord::Base + attr_accessible :name, :email +end diff --git a/db/migrate/20100821203213_create_users.rb b/db/migrate/20100821203213_create_users.rb new file mode 100644 index 0000000..805ba7b --- /dev/null +++ b/db/migrate/20100821203213_create_users.rb @@ -0,0 +1,14 @@ +class CreateUsers < ActiveRecord::Migration + def self.up + create_table :users do |t| + t.string :name + t.string :email + + t.timestamps + end + end + + def self.down + drop_table :users + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000..aef486a --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,22 @@ +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended to check this file into your version control system. + +ActiveRecord::Schema.define(:version => 20100821203213) do + + create_table "users", :force => true do |t| + t.string "name" + t.string "email" + t.datetime "created_at" + t.datetime "updated_at" + end + +end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb new file mode 100644 index 0000000..44032b4 --- /dev/null +++ b/spec/models/user_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe User do + pending "add some examples to (or delete) #{__FILE__}" +end