Permalink
Browse files

generated models with

  $ r g active_record:model todo title:string done:boolean
  $ r g model todo_log title:string done:boolean

and add schema options: :null, :default
  • Loading branch information...
1 parent a0de08b commit 8d8e9f6346ee291acaab5165b82561e4677ab519 @a2ikm committed Jul 30, 2011
Showing with 43 additions and 0 deletions.
  1. +2 −0 app/models/todo.rb
  2. +5 −0 app/models/todo_log.rb
  3. +14 −0 db/migrate/20110730071022_create_todos.rb
  4. +22 −0 db/schema.rb
View
@@ -0,0 +1,2 @@
+class Todo < ActiveRecord::Base
+end
View
@@ -0,0 +1,5 @@
+class TodoLog
+ include Mongoid::Document
+ field :title, :type => String
+ field :done, :type => Boolean
+end
@@ -0,0 +1,14 @@
+class CreateTodos < ActiveRecord::Migration
+ def self.up
+ create_table :todos do |t|
+ t.string :title, :null => false
+ t.boolean :done, :null => false, :default => false
+
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :todos
+ end
+end
View
@@ -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 => 20110730071022) do
+
+ create_table "todos", :force => true do |t|
+ t.string "title", :null => false
+ t.boolean "done", :default => false, :null => false
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+end

0 comments on commit 8d8e9f6

Please sign in to comment.