Skip to content

Commit

Permalink
Added migration, model and requireds.
Browse files Browse the repository at this point in the history
  • Loading branch information
Antony Ryabov committed Nov 24, 2015
1 parent 412226f commit 8cc1a84
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/core.rb
Expand Up @@ -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 }

3 changes: 3 additions & 0 deletions app/models/note.rb
@@ -0,0 +1,3 @@
class Note < ActiveRecord::Base
validates :author, :title, :body, presence: true
end
1 change: 0 additions & 1 deletion config.ru
Expand Up @@ -3,7 +3,6 @@ require 'rubygems'
require 'bundler/setup'
require 'grape'
require './app/core'
require './app/api/notes'

use ActiveRecord::ConnectionAdapters::ConnectionManagement

Expand Down
15 changes: 15 additions & 0 deletions db/migrate/20151124152422_create_table_notes.rb
@@ -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
29 changes: 29 additions & 0 deletions db/schema.rb
@@ -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.