Commit 4a6a1c2ed3bef62e1a27227db41b63e1ba7a99c9
Committed by
Rafael Manzo
1 parent
fa1013f0
Exists in
colab
and in
4 other branches
Created ProjectOwnership model
Already associated it with User
Showing
7 changed files
with
41 additions
and
1 deletions
Show diff stats
app/models/user.rb
@@ -8,5 +8,6 @@ class User < ActiveRecord::Base | @@ -8,5 +8,6 @@ class User < ActiveRecord::Base | ||
8 | validates :email, presence: true | 8 | validates :email, presence: true |
9 | validates :email, uniqueness: true | 9 | validates :email, uniqueness: true |
10 | 10 | ||
11 | + has_many :project_ownerships | ||
11 | # Alert: when adding new parameters to this model, they should also be added to registrations_controller | 12 | # Alert: when adding new parameters to this model, they should also be added to registrations_controller |
12 | end | 13 | end |
db/schema.rb
@@ -11,7 +11,14 @@ | @@ -11,7 +11,14 @@ | ||
11 | # | 11 | # |
12 | # It's strongly recommended that you check this file into your version control system. | 12 | # It's strongly recommended that you check this file into your version control system. |
13 | 13 | ||
14 | -ActiveRecord::Schema.define(version: 20130627183652) do | 14 | +ActiveRecord::Schema.define(version: 20130826211404) do |
15 | + | ||
16 | + create_table "project_ownerships", force: true do |t| | ||
17 | + t.integer "user_id" | ||
18 | + t.integer "project_id" | ||
19 | + t.datetime "created_at" | ||
20 | + t.datetime "updated_at" | ||
21 | + end | ||
15 | 22 | ||
16 | create_table "users", force: true do |t| | 23 | create_table "users", force: true do |t| |
17 | t.string "name", default: "", null: false | 24 | t.string "name", default: "", null: false |
spec/models/user_spec.rb
@@ -8,4 +8,8 @@ describe User do | @@ -8,4 +8,8 @@ describe User do | ||
8 | it { should validate_presence_of(:email) } | 8 | it { should validate_presence_of(:email) } |
9 | it { should validate_uniqueness_of(:email) } | 9 | it { should validate_uniqueness_of(:email) } |
10 | end | 10 | end |
11 | + | ||
12 | + describe 'associations' do | ||
13 | + it { should have_many(:project_ownerships) } | ||
14 | + end | ||
11 | end | 15 | end |