Showing
7 changed files
with
43 additions
and
1 deletions
app/models/group.rb
0 → 100644
... | @@ -16,6 +16,8 @@ class Pool < ApplicationRecord | ... | @@ -16,6 +16,8 @@ class Pool < ApplicationRecord |
16 | validates :name, :editable_until, presence: true | 16 | validates :name, :editable_until, presence: true |
17 | 17 | ||
18 | has_many :matches, dependent: :destroy, inverse_of: :pool | 18 | has_many :matches, dependent: :destroy, inverse_of: :pool |
19 | + has_many :groups, inverse_of: :pool | ||
20 | + has_many :users, through: :groups, inverse_of: :pools | ||
19 | 21 | ||
20 | scope :active, -> { where(active: true) } | 22 | scope :active, -> { where(active: true) } |
21 | accepts_nested_attributes_for :matches, reject_if: :all_blank, | 23 | accepts_nested_attributes_for :matches, reject_if: :all_blank, | ... | ... |
... | @@ -27,6 +27,8 @@ class User < ApplicationRecord | ... | @@ -27,6 +27,8 @@ class User < ApplicationRecord |
27 | before_save :encrypt_password | 27 | before_save :encrypt_password |
28 | 28 | ||
29 | has_many :bets, inverse_of: :user | 29 | has_many :bets, inverse_of: :user |
30 | + has_many :groups, inverse_of: :user | ||
31 | + has_many :pools, through: :groups, inverse_of: :users | ||
30 | 32 | ||
31 | has_and_belongs_to_many :roles, inverse_of: :users, | 33 | has_and_belongs_to_many :roles, inverse_of: :users, |
32 | class_name: 'HeimdallEngine::Role', | 34 | class_name: 'HeimdallEngine::Role', | ... | ... |
db/migrate/20180611152223_create_groups.rb
0 → 100644
... | @@ -10,7 +10,7 @@ | ... | @@ -10,7 +10,7 @@ |
10 | # | 10 | # |
11 | # It's strongly recommended that you check this file into your version control system. | 11 | # It's strongly recommended that you check this file into your version control system. |
12 | 12 | ||
13 | -ActiveRecord::Schema.define(version: 20180608221342) do | 13 | +ActiveRecord::Schema.define(version: 20180611152223) do |
14 | 14 | ||
15 | # These are extensions that must be enabled in order to support this database | 15 | # These are extensions that must be enabled in order to support this database |
16 | enable_extension "plpgsql" | 16 | enable_extension "plpgsql" |
... | @@ -24,6 +24,15 @@ ActiveRecord::Schema.define(version: 20180608221342) do | ... | @@ -24,6 +24,15 @@ ActiveRecord::Schema.define(version: 20180608221342) do |
24 | t.integer "points" | 24 | t.integer "points" |
25 | end | 25 | end |
26 | 26 | ||
27 | + create_table "groups", force: :cascade do |t| | ||
28 | + t.integer "user_id" | ||
29 | + t.integer "pool_id" | ||
30 | + t.datetime "created_at", null: false | ||
31 | + t.datetime "updated_at", null: false | ||
32 | + t.index ["pool_id"], name: "index_groups_on_pool_id", using: :btree | ||
33 | + t.index ["user_id"], name: "index_groups_on_user_id", using: :btree | ||
34 | + end | ||
35 | + | ||
27 | create_table "heimdall_engine_role_abilities", force: :cascade do |t| | 36 | create_table "heimdall_engine_role_abilities", force: :cascade do |t| |
28 | t.integer "role_id" | 37 | t.integer "role_id" |
29 | t.string "key" | 38 | t.string "key" | ... | ... |
test/fixtures/groups.yml
0 → 100644
-
Please register or login to post a comment