Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Patricio Sanchez
/
quiniela-mundial
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Iker Narvaez
2018-06-11 10:28:18 -0500
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
09b0461f5b6bf959684142a265f35d2815a58ecc
09b0461f
1 parent
ac9dea98
fix group structure
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
23 additions
and
8 deletions
app/models/group.rb
app/models/pool.rb
app/models/user.rb
config/routes.rb
db/migrate/20180611152223_create_groups.rb
db/migrate/20180611152633_create_group_user.rb
db/schema.rb
app/models/group.rb
View file @
09b0461
class
Group
<
ApplicationRecord
belongs_to
:user
,
->
{
with_deleted
},
inverse_of: :groups
belongs_to
:pool
,
->
{
with_deleted
},
inverse_of: :groups
has_and_belongs_to_many
:users
,
inverse_of: :groups
validates
:name
,
:pool
,
presence:
true
end
...
...
app/models/pool.rb
View file @
09b0461
...
...
@@ -17,7 +17,6 @@ class Pool < ApplicationRecord
has_many
:matches
,
dependent: :destroy
,
inverse_of: :pool
has_many
:groups
,
inverse_of: :pool
has_many
:users
,
through: :groups
,
inverse_of: :pools
scope
:active
,
->
{
where
(
active:
true
)
}
accepts_nested_attributes_for
:matches
,
reject_if: :all_blank
,
...
...
app/models/user.rb
View file @
09b0461
...
...
@@ -27,8 +27,7 @@ class User < ApplicationRecord
before_save
:encrypt_password
has_many
:bets
,
inverse_of: :user
has_many
:groups
,
inverse_of: :user
has_many
:pools
,
through: :groups
,
inverse_of: :users
has_and_belongs_to_many
:groups
,
inverse_of: :users
has_and_belongs_to_many
:roles
,
inverse_of: :users
,
class_name:
'HeimdallEngine::Role'
,
...
...
config/routes.rb
View file @
09b0461
...
...
@@ -10,5 +10,6 @@ Rails.application.routes.draw do
namespace
:admin
do
resources
:pools
resources
:groups
end
end
...
...
db/migrate/20180611152223_create_groups.rb
View file @
09b0461
class
CreateGroups
<
ActiveRecord
::
Migration
[
5
.
0
]
def
change
create_table
:groups
do
|
t
|
t
.
integer
:user_id
,
index:
true
t
.
integer
:pool_id
,
index:
true
t
.
string
:name
t
.
timestamps
end
end
...
...
db/migrate/20180611152633_create_group_user.rb
0 → 100644
View file @
09b0461
class
CreateGroupUser
<
ActiveRecord
::
Migration
[
5
.
0
]
def
change
create_table
:group_users
do
|
t
|
t
.
integer
:group_id
,
index:
true
t
.
integer
:user_id
,
index:
true
end
end
end
db/schema.rb
View file @
09b0461
...
...
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
20180611152
22
3
)
do
ActiveRecord
::
Schema
.
define
(
version:
20180611152
63
3
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
@@ -24,13 +24,19 @@ ActiveRecord::Schema.define(version: 20180611152223) do
t
.
integer
"points"
end
create_table
"groups"
,
force: :cascade
do
|
t
|
create_table
"group_users"
,
force: :cascade
do
|
t
|
t
.
integer
"group_id"
t
.
integer
"user_id"
t
.
index
[
"group_id"
],
name:
"index_group_users_on_group_id"
,
using: :btree
t
.
index
[
"user_id"
],
name:
"index_group_users_on_user_id"
,
using: :btree
end
create_table
"groups"
,
force: :cascade
do
|
t
|
t
.
integer
"pool_id"
t
.
string
"name"
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
index
[
"pool_id"
],
name:
"index_groups_on_pool_id"
,
using: :btree
t
.
index
[
"user_id"
],
name:
"index_groups_on_user_id"
,
using: :btree
end
create_table
"heimdall_engine_role_abilities"
,
force: :cascade
do
|
t
|
...
...
Please
register
or
login
to post a comment