added associations for models

parent 40b5c492
class Candidate < ApplicationRecord
belongs_to :position
end
class Position < ApplicationRecord
has_many :candidates
end
class CreatePositions < ActiveRecord::Migration[5.0]
def change
create_table :positions do |t|
t.string :name
t.timestamps
end
end
end
......@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160718135122) do
ActiveRecord::Schema.define(version: 20160718135621) do
create_table "candidates", force: :cascade do |t|
t.string "first_name"
......@@ -22,6 +22,12 @@ ActiveRecord::Schema.define(version: 20160718135122) do
t.datetime "updated_at", null: false
end
create_table "positions", force: :cascade do |t|
t.string "name"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "users", force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
......
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
name: MyString
two:
name: MyString
require 'test_helper'
class PositionTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment