Showing
4 changed files
with
32 additions
and
3 deletions
app/controllers/admin/pools_controller.rb
0 → 100644
app/models/pool.rb
0 → 100644
| 1 | +# frozen_string_literal: true | ||
| 2 | + | ||
| 3 | +# == Schema Information | ||
| 4 | +# | ||
| 5 | +# Table name: heimdall_engine_roles | ||
| 6 | +# | ||
| 7 | +# id :integer not null, primary key | ||
| 8 | +# name :string | ||
| 9 | +# created_at :datetime | ||
| 10 | +# updated_at :datetime | ||
| 11 | +# deleted_at :datetime | ||
| 12 | +# erasable :boolean | ||
| 13 | +# | ||
| 14 | +class Pool < ApplicationRecord | ||
| 15 | + | ||
| 16 | + validates :name, :editable_unitl, presence: true | ||
| 17 | + | ||
| 18 | + has_many :matches, dependent: :destroy, inverse_of: :pool | ||
| 19 | + | ||
| 20 | + accepts_nested_attributes_for :matches, reject_if: :all_blank, | ||
| 21 | + allow_destroy: true | ||
| 22 | +end | 
| ... | @@ -2,4 +2,6 @@ Rails.application.routes.draw do | ... | @@ -2,4 +2,6 @@ Rails.application.routes.draw do | 
| 2 | # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html | 2 | # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html | 
| 3 | HeimdallEngine.load_routes | 3 | HeimdallEngine.load_routes | 
| 4 | root 'application#root' | 4 | root 'application#root' | 
| 5 | + | ||
| 6 | + resources :pools | ||
| 5 | end | 7 | end | ... | ... | 
| 1 | class CreateProject < ActiveRecord::Migration[5.0] | 1 | class CreateProject < ActiveRecord::Migration[5.0] | 
| 2 | def change | 2 | def change | 
| 3 | - create_table :match do |t| | 3 | + create_table :matches do |t| | 
| 4 | t.string :local, null: false | 4 | t.string :local, null: false | 
| 5 | t.string :visit, null: false | 5 | t.string :visit, null: false | 
| 6 | t.date :date, null: false | 6 | t.date :date, null: false | 
| ... | @@ -10,13 +10,13 @@ class CreateProject < ActiveRecord::Migration[5.0] | ... | @@ -10,13 +10,13 @@ class CreateProject < ActiveRecord::Migration[5.0] | 
| 10 | t.integer :pool_id, null: false | 10 | t.integer :pool_id, null: false | 
| 11 | end | 11 | end | 
| 12 | 12 | ||
| 13 | - create_table :pool do |t| | 13 | + create_table :pools do |t| | 
| 14 | t.string :name, null: false | 14 | t.string :name, null: false | 
| 15 | t.datetime :editable_until, null: false | 15 | t.datetime :editable_until, null: false | 
| 16 | t.boolean :active | 16 | t.boolean :active | 
| 17 | end | 17 | end | 
| 18 | 18 | ||
| 19 | - create_table :bet do |t| | 19 | + create_table :bets do |t| | 
| 20 | t.integer :match_id, null: false | 20 | t.integer :match_id, null: false | 
| 21 | t.integer :user_id, null: false | 21 | t.integer :user_id, null: false | 
| 22 | t.integer :score_local, null: false | 22 | t.integer :score_local, null: false | ... | ... | 
- 
Please register or login to post a comment