Permalink
Browse files

Added migration, model and requireds.

  • Loading branch information...
tonymadbrain committed Nov 24, 2015
1 parent 412226f commit 8cc1a849097b5c62a8beacb2296ab7f0e74b7fdc
Showing with 49 additions and 2 deletions.
  1. +2 −1 app/core.rb
  2. +3 −0 app/models/note.rb
  3. +0 −1 config.ru
  4. +15 −0 db/migrate/20151124152422_create_table_notes.rb
  5. +29 −0 db/schema.rb
View
@@ -4,5 +4,6 @@
Bundler.require
app_base = "#{File.dirname(File.expand_path(__FILE__))}/.."
Dir.glob("#{app_base}/app/api/**/*.rb").each { |i| require i }
Dir.glob("#{app_base}/app/models/**/*.rb").each { |i| require i }
Dir.glob("#{app_base}/app/lib/**/*.rb").each { |i| require i }
View
@@ -0,0 +1,3 @@
class Note < ActiveRecord::Base
validates :author, :title, :body, presence: true
end
View
@@ -3,7 +3,6 @@ require 'rubygems'
require 'bundler/setup'
require 'grape'
require './app/core'
require './app/api/notes'
use ActiveRecord::ConnectionAdapters::ConnectionManagement
@@ -0,0 +1,15 @@
class CreateTableNotes < ActiveRecord::Migration
def change
create_table :notes do |t|
t.string :author
t.string :title
t.text :content
t.text :summary
t.boolean :private, default: false
t.integer :valuation
t.timestamps null: false
end
add_index :notes, :author
end
end
View
@@ -0,0 +1,29 @@
# encoding: UTF-8
# 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 that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20151124152422) do
create_table "notes", force: :cascade do |t|
t.string "author", limit: 255
t.string "title", limit: 255
t.text "content", limit: 65535
t.text "summary", limit: 65535
t.boolean "private", default: false
t.integer "valuation", limit: 4
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "notes", ["author"], name: "index_notes_on_author", using: :btree
end

0 comments on commit 8cc1a84

Please sign in to comment.