From dbfd5447c3a9c6e20728d83794e6315dff6ed36a Mon Sep 17 00:00:00 2001 From: ericbowman Date: Fri, 7 Jun 2019 10:37:58 -0400 Subject: [PATCH] Add user to tunes --- config/routes.rb | 2 +- db/migrate/20190607143547_add_user_to_tunes.rb | 5 +++++ db/schema.rb | 5 ++++- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20190607143547_add_user_to_tunes.rb diff --git a/config/routes.rb b/config/routes.rb index c6f9ced..0895866 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Rails.application.routes.draw do - resources :tunes + resources :tunes, except: %i[new edit] # RESTful routes resources :examples, except: %i[new edit] diff --git a/db/migrate/20190607143547_add_user_to_tunes.rb b/db/migrate/20190607143547_add_user_to_tunes.rb new file mode 100644 index 0000000..359ff0f --- /dev/null +++ b/db/migrate/20190607143547_add_user_to_tunes.rb @@ -0,0 +1,5 @@ +class AddUserToTunes < ActiveRecord::Migration[5.2] + def change + add_reference :tunes, :user, foreign_key: true + end +end diff --git a/db/schema.rb b/db/schema.rb index e35602b..6fce1b2 100755 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2019_06_07_142623) do +ActiveRecord::Schema.define(version: 2019_06_07_143547) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -28,6 +28,8 @@ t.string "composer" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.bigint "user_id" + t.index ["user_id"], name: "index_tunes_on_user_id" end create_table "users", force: :cascade do |t| @@ -41,4 +43,5 @@ end add_foreign_key "examples", "users" + add_foreign_key "tunes", "users" end