1
0
Fork 0

Add all the basic models

This commit is contained in:
Andrew Tomaka 2015-10-06 13:55:12 -04:00
parent 6a36a7e61c
commit da3d78a32a
95 changed files with 1098 additions and 12 deletions

1
.gitignore vendored
View file

@ -18,3 +18,4 @@
# mine # mine
.env .env
erd.pdf

View file

@ -26,5 +26,6 @@ group :development do
gem 'quiet_assets' gem 'quiet_assets'
gem 'web-console', '~> 2.0' gem 'web-console', '~> 2.0'
gem 'spring' gem 'spring'
gem 'rails-erd'
end end

View file

@ -58,6 +58,7 @@ GEM
sass (>= 3.3.0) sass (>= 3.3.0)
builder (3.2.2) builder (3.2.2)
byebug (6.0.2) byebug (6.0.2)
choice (0.2.0)
coderay (1.1.0) coderay (1.1.0)
coffee-rails (4.1.0) coffee-rails (4.1.0)
coffee-script (>= 2.2.0) coffee-script (>= 2.2.0)
@ -134,6 +135,11 @@ GEM
activesupport (>= 4.2.0.beta, < 5.0) activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0) nokogiri (~> 1.6.0)
rails-deprecated_sanitizer (>= 1.0.1) rails-deprecated_sanitizer (>= 1.0.1)
rails-erd (1.4.3)
activerecord (>= 3.2)
activesupport (>= 3.2)
choice (~> 0.2.0)
ruby-graphviz (~> 1.2)
rails-html-sanitizer (1.0.2) rails-html-sanitizer (1.0.2)
loofah (~> 2.0) loofah (~> 2.0)
railties (4.2.4) railties (4.2.4)
@ -143,6 +149,7 @@ GEM
thor (>= 0.18.1, < 2.0) thor (>= 0.18.1, < 2.0)
rake (10.4.2) rake (10.4.2)
rdoc (4.2.0) rdoc (4.2.0)
ruby-graphviz (1.2.2)
sass (3.4.18) sass (3.4.18)
sass-rails (5.0.4) sass-rails (5.0.4)
railties (>= 4.0.0, < 5.0) railties (>= 4.0.0, < 5.0)
@ -202,6 +209,7 @@ DEPENDENCIES
omniauth-reddit! omniauth-reddit!
quiet_assets quiet_assets
rails (= 4.2.4) rails (= 4.2.4)
rails-erd
sass-rails (~> 5.0) sass-rails (~> 5.0)
sdoc (~> 0.4.0) sdoc (~> 0.4.0)
simple_form simple_form

View file

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View file

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View file

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View file

@ -1,2 +0,0 @@
$ ->
$(".button-collapse").sideNav()

View file

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View file

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View file

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View file

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View file

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View file

@ -0,0 +1,3 @@
// Place all the styles related to the AwakenTypes controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View file

@ -0,0 +1,3 @@
// Place all the styles related to the Cards controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View file

@ -0,0 +1,3 @@
// Place all the styles related to the Character controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View file

@ -0,0 +1,3 @@
// Place all the styles related to the LeaderSkills controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View file

@ -0,0 +1,3 @@
// Place all the styles related to the PassiveSkills controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View file

@ -0,0 +1,3 @@
// Place all the styles related to the Rarities controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View file

@ -0,0 +1,3 @@
// Place all the styles related to the SuperAttacks controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View file

@ -0,0 +1,3 @@
// Place all the styles related to the Types controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View file

@ -0,0 +1,51 @@
class AwakenTypesController < ApplicationController
before_action :set_awaken_type, only: [:show, :edit, :update, :destroy]
def index
@awaken_types = AwakenType.all
end
def show
end
def new
@awaken_type = AwakenType.new
end
def create
@awaken_type = AwakenType.new(awaken_type_params)
if @awaken_type.save
redirect_to awaken_types_path, notice: 'Awaken Type was created'
else
render :new
end
end
def edit
end
def update
if @awaken_type.update(awaken_type_params)
redirect_to awaken_types_path, notice: 'Awaken Type was updated'
else
render :edit
end
end
def destroy
@awaken_type.destroy
redirect_to awaken_types_path, notice: 'Awaken Type was deleted'
end
private
def awaken_type_params
params.require(:awaken_type).permit(:name)
end
def set_awaken_type
@awaken_type = AwakenType.find(params[:id])
end
end

View file

@ -0,0 +1,54 @@
class CardsController < ApplicationController
before_action :set_card, only: [:show, :edit, :update, :destroy]
def index
@cards = Card.all
end
def show
end
def new
@card = Card.new
end
def create
@card = Card.new(card_params)
if @card.save
redirect_to cards_path, notice: 'Card was created'
else
render :new
end
end
def edit
end
def update
if @card.update(card_params)
redirect_to cards_path, notice: 'Card was updated'
else
render :edit
end
end
def destroy
@card.destroy
redirect_to cards_path, notice: 'Card was deleted'
end
private
def card_params
params.require(:card).permit(:prefix, :character_id, :rarity_id, :type_id,
:leader_skill_id, :passive_skill_id,
:super_attack_id, :dokkan_id, :gameid,
:awaken_type_id, link_ids: [])
end
def set_card
@card = Card.find(params[:id])
end
end

View file

@ -0,0 +1,51 @@
class CharactersController < ApplicationController
before_action :set_character, only: [:show, :edit, :update, :destroy]
def index
@characters = Character.all
end
def show
end
def new
@character = Character.new
end
def create
@character = Character.new(character_params)
if @character.save
redirect_to characters_path, notice: 'Character was created'
else
render :new
end
end
def edit
end
def update
if @character.update(character_params)
redirect_to characters_path, notice: 'Character was updated'
else
render :edit
end
end
def destroy
@character.destroy
redirect_to characters_path, notice: 'Character was deleted'
end
private
def character_params
params.require(:character).permit(:name)
end
def set_character
@character = Character.find(params[:id])
end
end

View file

@ -0,0 +1,51 @@
class LeaderSkillsController < ApplicationController
before_action :set_leader_skill, only: [:show, :edit, :update, :destroy]
def index
@leader_skills = LeaderSkill.all
end
def show
end
def new
@leader_skill = LeaderSkill.new
end
def create
@leader_skill = LeaderSkill.new(leader_skill_params)
if @leader_skill.save
redirect_to leader_skills_path, notice: 'Leader Skill was created'
else
render :new
end
end
def edit
end
def update
if @leader_skill.update(leader_skill_params)
redirect_to leader_skills_path, notice: 'Leader Skill was updated'
else
render :edit
end
end
def destroy
@leader_skill.destroy
redirect_to leader_skills_path, notice: 'Leader Skills was deleted'
end
private
def leader_skill_params
params.require(:leader_skill).permit(:name, :description)
end
def set_leader_skill
@leader_skill = LeaderSkill.find(params[:id])
end
end

View file

@ -0,0 +1,51 @@
class PassiveSkillsController < ApplicationController
before_action :set_passive_skill, only: [:show, :edit, :update, :destroy]
def index
@passive_skills = PassiveSkill.all
end
def show
end
def new
@passive_skill = PassiveSkill.new
end
def create
@passive_skill = PassiveSkill.new(passive_skill_params)
if @passive_skill.save
redirect_to passive_skills_path, notice: 'Passive Skill was created'
else
render :new
end
end
def edit
end
def update
if @passive_skill.update(passive_skill_params)
redirect_to passive_skills_path, notice: 'Passive Skill was updated'
else
render :edit
end
end
def destroy
@passive_skill.destroy
redirect_to passive_skills_path, notice: 'Passive Skill was deleted'
end
private
def passive_skill_params
params.require(:passive_skill).permit(:name, :description)
end
def set_passive_skill
@passive_skill = PassiveSkill.find(params[:id])
end
end

View file

@ -0,0 +1,51 @@
class RaritiesController < ApplicationController
before_action :set_rarity, only: [:show, :edit, :update, :destroy]
def index
@rarities = Rarity.all
end
def show
end
def new
@rarity = Rarity.new
end
def create
@rarity = Rarity.new(rarity_params)
if @rarity.save
redirect_to rarities_path, notice: 'Rarity was created'
else
render :new
end
end
def edit
end
def update
if @rarity.update(rarity_params)
redirect_to rarities_path, notice: 'Rarity was updated'
else
render :edit
end
end
def destroy
@rarity.destroy
redirect_to rarities_path, notice: 'Rarity was deleted'
end
private
def rarity_params
params.require(:rarity).permit(:name, :description)
end
def set_rarity
@rarity = Rarity.find(params[:id])
end
end

View file

@ -0,0 +1,51 @@
class SuperAttacksController < ApplicationController
before_action :set_super_attack, only: [:show, :edit, :update, :destroy]
def index
@super_attacks = SuperAttack.all
end
def show
end
def new
@super_attack = SuperAttack.new
end
def create
@super_attack = SuperAttack.new(super_attack_params)
if @super_attack.save
redirect_to super_attacks_path, notice: 'Super Attack was created'
else
render :new
end
end
def edit
end
def update
if @super_attack.update(super_attack_params)
redirect_to super_attacks_path, notice: 'Super Attack was updated'
else
render :edit
end
end
def destroy
@super_attack.destroy
redirect_to super_attacks_path, notice: 'Super Attack was deleted'
end
private
def super_attack_params
params.require(:super_attack).permit(:name, :description)
end
def set_super_attack
@super_attack = SuperAttack.find(params[:id])
end
end

View file

@ -0,0 +1,51 @@
class TypesController < ApplicationController
before_action :set_type, only: [:show, :edit, :update, :destroy]
def index
@types = Type.all
end
def show
end
def new
@type = Type.new
end
def create
@type = Type.new(type_params)
if @type.save
redirect_to types_path, notice: 'Type was created'
else
render :new
end
end
def edit
end
def update
if @type.update(type_params)
redirect_to types_path, notice: 'Type was updated'
else
render :edit
end
end
def destroy
@type.destroy
redirect_to types_path, notice: 'Type was deleted'
end
private
def type_params
params.require(:type).permit(:name, :description)
end
def set_type
@type = Type.find(params[:id])
end
end

View file

@ -16,6 +16,10 @@ module ApplicationHelper
content_tag(:i, class: "glyphicon glyphicon-#{icon} " + classes) {} content_tag(:i, class: "glyphicon glyphicon-#{icon} " + classes) {}
end end
def login_path(provider)
"/auth/#{provider.to_s}"
end
private private
def bootstrap_classes def bootstrap_classes

View file

@ -0,0 +1,2 @@
module AwakenTypesHelper
end

View file

@ -0,0 +1,2 @@
module CardsHelper
end

View file

@ -0,0 +1,2 @@
module CharactersHelper
end

View file

@ -0,0 +1,2 @@
module LeaderSkillsHelper
end

View file

@ -0,0 +1,2 @@
module PassiveSkillsHelper
end

View file

@ -0,0 +1,2 @@
module RaritiesHelper
end

View file

@ -0,0 +1,2 @@
module SuperAttacksHelper
end

View file

@ -0,0 +1,2 @@
module TypesHelper
end

View file

@ -0,0 +1,3 @@
class AwakenType < ActiveRecord::Base
validates :name, presence: true
end

27
app/models/card.rb Normal file
View file

@ -0,0 +1,27 @@
class Card < ActiveRecord::Base
belongs_to :character
belongs_to :rarity
belongs_to :type
belongs_to :leader_skill
belongs_to :passive_skill
belongs_to :super_attack
belongs_to :awaken_type
has_one :dokkan_card, class_name: 'Card', foreign_key: :dokkan_id
has_and_belongs_to_many :links
delegate :name, to: :character, prefix: false
validates :prefix, presence: true
validates :character, presence: true
validates :gameid, presence: true,
numericality: { only_integer: true },
length: { is: 7 }
validates :rarity, presence: true
validates :type, presence: true
validates :awaken_type, presence: true
def dokkan?
self.dokkan_id != nil
end
end

4
app/models/cards_link.rb Normal file
View file

@ -0,0 +1,4 @@
class CardsLink < ActiveRecord::Base
belongs_to :card
belongs_to :link
end

4
app/models/character.rb Normal file
View file

@ -0,0 +1,4 @@
class Character < ActiveRecord::Base
validates :name, presence: true,
uniqueness: { case_sensitive: false }
end

View file

@ -0,0 +1,4 @@
class LeaderSkill < ActiveRecord::Base
validates :name, presence: true
validates :description, presence: true
end

View file

@ -1,4 +1,6 @@
class Link < ActiveRecord::Base class Link < ActiveRecord::Base
has_and_belongs_to_many :cards
validates :name, presence: true, validates :name, presence: true,
uniqueness: true uniqueness: true
end end

2
app/models/medal.rb Normal file
View file

@ -0,0 +1,2 @@
class Medal < ActiveRecord::Base
end

View file

@ -0,0 +1,4 @@
class PassiveSkill < ActiveRecord::Base
validates :name, presence: true
validates :description, presence: true
end

5
app/models/rarity.rb Normal file
View file

@ -0,0 +1,5 @@
class Rarity < ActiveRecord::Base
validates :name, presence: true,
uniqueness: { case_sensitive: false }
validates :description, presence: true
end

View file

@ -0,0 +1,4 @@
class SuperAttack < ActiveRecord::Base
validates :name, presence: true
validates :description, presence: true
end

5
app/models/type.rb Normal file
View file

@ -0,0 +1,5 @@
class Type < ActiveRecord::Base
validates :name, presence: true,
uniqueness: { case_sensitive: false }
validates :description, presence: true
end

View file

@ -9,8 +9,26 @@
= link_to 'DBZDokkan', root_path, class: 'navbar-brand' = link_to 'DBZDokkan', root_path, class: 'navbar-brand'
.collapse.navbar-collapse .collapse.navbar-collapse
ul.nav.navbar-nav.navbar-right ul.nav.navbar-nav.navbar-right
li= nav_link_to 'Links', links_path li.dropdown
a href='#' class='dropdown-toggle' data-toggle='dropdown'
= 'Abilities '
span class='caret'
ul.dropdown-menu
li= link_to 'Links', links_path
li= link_to 'Leader Skills', leader_skills_path
li= link_to 'Passive Skills', passive_skills_path
li= link_to 'Super Attacks', super_attacks_path
li= nav_link_to 'Cards', cards_path
li= nav_link_to 'Characters', characters_path
li.dropdown
a href='#' class='dropdown-toggle' data-toggle='dropdown'
= 'Others '
span class='caret'
ul.dropdown-menu
li= link_to 'Awaken Types', awaken_types_path
li= link_to 'Rarities', rarities_path
li= link_to 'Types', types_path
- if logged_in? - if logged_in?
li= link_to 'Log Out', logout_path, method: :delete li= link_to 'Log Out', logout_path, method: :delete
- else - else
li= link_to 'Log In', '/auth/reddit' li= link_to 'Log In', login_path(:reddit)

View file

@ -0,0 +1,5 @@
= simple_form_for @awaken_type do |f|
.form-inputs
= f.input :name
.form-actions
= f.button :button

View file

@ -0,0 +1 @@
== render 'form'

View file

@ -0,0 +1,23 @@
.row
.col-md-12
.pull-right
= link_to 'New Awaken Type', new_awaken_type_path, class: 'btn btn-primary'
.row
.col-md-12
table.table.table-striped.table-hover
thead
tr
th Name
th Actions
tbody
- @awaken_types.each do |awaken_type|
tr
td= awaken_type.name
td
= link_to glyph('edit', classes: 'control-icon'), edit_awaken_type_path(awaken_type)
= link_to glyph('trash', classes: 'control-icon'), awaken_type_path(awaken_type), method: :delete
.row
.col-md-12
= link_to 'New Awaken Type', new_awaken_type_path, class: 'btn btn-primary'

View file

@ -0,0 +1 @@
== render 'form'

View file

@ -0,0 +1,31 @@
= simple_form_for @card do |f|
.form-inputs
.row
.col-md-4
= f.input :gameid, label: 'Game ID Number'
.col-md-4
= f.input :prefix
.col-md-4
= f.association :character
.row
.col-md-4
= f.association :rarity
.col-md-4
= f.association :type
.col-md-4
= f.association :awaken_type
.row
.col-md-6
= f.association :leader_skill
.col-md-6
= f.association :passive_skill
.row
.col-md-6
= f.association :super_attack
.row
.col-md-12
= f.label :links
div
= f.association :links, as: :check_boxes, item_wrapper_tag: nil, item_label_class: 'checkbox-inline', label: false
.form-actions
= f.button :button

View file

@ -0,0 +1 @@
== render 'form'

View file

@ -0,0 +1,25 @@
.row
.col-md-12
.pull-right
= link_to 'New Card', new_card_path, class: 'btn btn-primary'
.row
.col-md-12
table.table.table-striped.table-hover
thead
tr
th Prefix
th Name
th Actions
tbody
- @cards.each do |card|
tr
td= card.prefix
td= card.name
td
= link_to glyph('edit', classes: 'control-icon'), edit_card_path(card)
= link_to glyph('trash', classes: 'control-icon'), card_path(card), method: :delete
.row
.col-md-12
= link_to 'New Card', new_card_path, class: 'btn btn-primary'

View file

@ -0,0 +1 @@
== render 'form'

View file

@ -0,0 +1,5 @@
= simple_form_for @character do |f|
.form-inputs
= f.input :name
.form-actions
= f.button :button

View file

@ -0,0 +1 @@
== render 'form'

View file

@ -0,0 +1,23 @@
.row
.col-md-12
.pull-right
= link_to 'New Character', new_character_path, class: 'btn btn-primary'
.row
.col-md-12
table.table.table-striped.table-hover
thead
tr
th Name
th Actions
tbody
- @characters.each do |character|
tr
td= character.name
td
= link_to glyph('edit', classes: 'control-icon'), edit_character_path(character)
= link_to glyph('trash', classes: 'control-icon'), character_path(character), method: :delete
.row
.col-md-12
= link_to 'New Character', new_character_path, class: 'btn btn-primary'

View file

@ -0,0 +1 @@
== render 'form'

View file

@ -0,0 +1,6 @@
= simple_form_for @leader_skill do |f|
.form-inputs
= f.input :name
= f.input :description
.form-actions
= f.button :button

View file

@ -0,0 +1 @@
== render 'form'

View file

@ -0,0 +1,25 @@
.row
.col-md-12
.pull-right
= link_to 'New Leader Skill', new_leader_skill_path, class: 'btn btn-primary'
.row
.col-md-12
table.table.table-striped.table-hover
thead
tr
th Name
th Description
th Actions
tbody
- @leader_skills.each do |leader_skill|
tr
td= leader_skill.name
td= leader_skill.description
td
= link_to glyph('edit', classes: 'control-icon'), edit_leader_skill_path(leader_skill)
= link_to glyph('trash', classes: 'control-icon'), leader_skill_path(leader_skill), method: :delete
.row
.col-md-12
= link_to 'New Leader Skill', new_leader_skill_path, class: 'btn btn-primary'

View file

@ -0,0 +1 @@
== render 'form'

View file

@ -0,0 +1,6 @@
= simple_form_for @passive_skill do |f|
.form-inputs
= f.input :name
= f.input :description
.form-actions
= f.button :button

View file

@ -0,0 +1 @@
== render 'form'

View file

@ -0,0 +1,25 @@
.row
.col-md-12
.pull-right
= link_to 'New Passive Skill', new_passive_skill_path, class: 'btn btn-primary'
.row
.col-md-12
table.table.table-striped.table-hover
thead
tr
th Name
th Description
th Actions
tbody
- @passive_skills.each do |passive_skill|
tr
td= passive_skill.name
td= passive_skill.description
td
= link_to glyph('edit', classes: 'control-icon'), edit_passive_skill_path(passive_skill)
= link_to glyph('trash', classes: 'control-icon'), passive_skill_path(passive_skill), method: :delete
.row
.col-md-12
= link_to 'New Passive Skill', new_passive_skill_path, class: 'btn btn-primary'

View file

@ -0,0 +1 @@
== render 'form'

View file

@ -0,0 +1,6 @@
= simple_form_for @rarity do |f|
.form-inputs
= f.input :name
= f.input :description
.form-actions
= f.button :button

View file

@ -0,0 +1 @@
== render 'form'

View file

@ -0,0 +1,25 @@
.row
.col-md-12
.pull-right
= link_to 'New Rarity', new_rarity_path, class: 'btn btn-primary'
.row
.col-md-12
table.table.table-striped.table-hover
thead
tr
th Name
th Description
th Actions
tbody
- @rarities.each do |rarity|
tr
td= rarity.name
td= rarity.description
td
= link_to glyph('edit', classes: 'control-icon'), edit_rarity_path(rarity)
= link_to glyph('trash', classes: 'control-icon'), rarity_path(rarity), method: :delete
.row
.col-md-12
= link_to 'New Rarity', new_rarity_path, class: 'btn btn-primary'

View file

@ -0,0 +1 @@
== render 'form'

View file

@ -0,0 +1,6 @@
= simple_form_for @super_attack do |f|
.form-inputs
= f.input :name
= f.input :description
.form-actions
= f.button :button

View file

@ -0,0 +1 @@
== render 'form'

View file

@ -0,0 +1,25 @@
.row
.col-md-12
.pull-right
= link_to 'New Super Attack', new_super_attack_path, class: 'btn btn-primary'
.row
.col-md-12
table.table.table-striped.table-hover
thead
tr
th Name
th Description
th Actions
tbody
- @super_attacks.each do |super_attack|
tr
td= super_attack.name
td= super_attack.description
td
= link_to glyph('edit', classes: 'control-icon'), edit_super_attack_path(super_attack)
= link_to glyph('trash', classes: 'control-icon'), super_attack_path(super_attack), method: :delete
.row
.col-md-12
= link_to 'New Super Attack', new_super_attack_path, class: 'btn btn-primary'

View file

@ -0,0 +1 @@
== render 'form'

View file

@ -0,0 +1,6 @@
= simple_form_for @type do |f|
.form-inputs
= f.input :name
= f.input :description
.form-actions
= f.button :button

View file

@ -0,0 +1 @@
== render 'form'

View file

@ -0,0 +1,25 @@
.row
.col-md-12
.pull-right
= link_to 'New Type', new_type_path, class: 'btn btn-primary'
.row
.col-md-12
table.table.table-striped.table-hover
thead
tr
th Name
th Description
th Actions
tbody
- @types.each do |type|
tr
td= type.name
td= type.description
td
= link_to glyph('edit', classes: 'control-icon'), edit_type_path(type)
= link_to glyph('trash', classes: 'control-icon'), type_path(type), method: :delete
.row
.col-md-12
= link_to 'New Type', new_type_path, class: 'btn btn-primary'

View file

@ -0,0 +1 @@
== render 'form'

View file

@ -3,7 +3,15 @@ Rails.application.routes.draw do
get 'auth/failure', to: 'sessions#failure' get 'auth/failure', to: 'sessions#failure'
delete 'logout', to: 'sessions#destroy', as: 'logout' delete 'logout', to: 'sessions#destroy', as: 'logout'
resources :awaken_types
resources :cards
resources :characters
resources :leader_skills
resources :links resources :links
resources :passive_skills
resources :rarities
resources :super_attacks
resources :types
resources :welcome, only: [:index] resources :welcome, only: [:index]
root to: 'welcome#index' root to: 'welcome#index'

View file

@ -0,0 +1,9 @@
class CreateCharacters < ActiveRecord::Migration
def change
create_table :characters do |t|
t.string :name
t.timestamps null: false
end
end
end

View file

@ -0,0 +1,10 @@
class CreateRarities < ActiveRecord::Migration
def change
create_table :rarities do |t|
t.string :name
t.string :description
t.timestamps null: false
end
end
end

View file

@ -0,0 +1,10 @@
class CreateTypes < ActiveRecord::Migration
def change
create_table :types do |t|
t.string :name
t.string :description
t.timestamps null: false
end
end
end

View file

@ -0,0 +1,10 @@
class CreateMedals < ActiveRecord::Migration
def change
create_table :medals do |t|
t.string :name
t.text :location
t.timestamps null: false
end
end
end

View file

@ -0,0 +1,10 @@
class CreateLeaderSkills < ActiveRecord::Migration
def change
create_table :leader_skills do |t|
t.string :name
t.string :description
t.timestamps null: false
end
end
end

View file

@ -0,0 +1,10 @@
class CreatePassiveSkills < ActiveRecord::Migration
def change
create_table :passive_skills do |t|
t.string :name
t.string :description
t.timestamps null: false
end
end
end

View file

@ -0,0 +1,10 @@
class CreateSuperAttacks < ActiveRecord::Migration
def change
create_table :super_attacks do |t|
t.string :name
t.string :description
t.timestamps null: false
end
end
end

View file

@ -0,0 +1,17 @@
class CreateCards < ActiveRecord::Migration
def change
create_table :cards do |t|
t.references :character, index: true, foreign_key: true
t.references :rarity, index: true, foreign_key: true
t.references :type, index: true, foreign_key: true
t.references :leader_skill, index: true, foreign_key: true
t.references :passive_skill, index: true, foreign_key: true
t.references :super_attack, index: true, foreign_key: true
t.integer :dokkan_id, index: true, foreign_key: true
t.string :suffix
t.string :gameid
t.timestamps null: false
end
end
end

View file

@ -0,0 +1,10 @@
class CreateCardsLinks < ActiveRecord::Migration
def change
create_join_table :cards, :links do |t|
t.references :card, index: true, foreign_key: true
t.references :link, index: true, foreign_key: true
t.timestamps null: false
end
end
end

View file

@ -0,0 +1,6 @@
class FixCardFields < ActiveRecord::Migration
def change
change_column :cards, :gameid, :string, default: '0000000'
rename_column :cards, :suffix, :prefix
end
end

View file

@ -0,0 +1,11 @@
class CreateAwakenTypes < ActiveRecord::Migration
def change
create_table :awaken_types do |t|
t.string :name
t.timestamps null: false
end
add_reference :cards, :awaken_type, index: true
end
end

View file

@ -11,7 +11,60 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20151001151519) do ActiveRecord::Schema.define(version: 20151007164606) do
create_table "awaken_types", force: :cascade do |t|
t.string "name"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "cards", force: :cascade do |t|
t.integer "character_id"
t.integer "rarity_id"
t.integer "type_id"
t.integer "leader_skill_id"
t.integer "passive_skill_id"
t.integer "super_attack_id"
t.integer "dokkan_id"
t.string "prefix"
t.string "gameid", default: "0000000"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "awaken_type_id"
end
add_index "cards", ["awaken_type_id"], name: "index_cards_on_awaken_type_id"
add_index "cards", ["character_id"], name: "index_cards_on_character_id"
add_index "cards", ["dokkan_id"], name: "index_cards_on_dokkan_id"
add_index "cards", ["leader_skill_id"], name: "index_cards_on_leader_skill_id"
add_index "cards", ["passive_skill_id"], name: "index_cards_on_passive_skill_id"
add_index "cards", ["rarity_id"], name: "index_cards_on_rarity_id"
add_index "cards", ["super_attack_id"], name: "index_cards_on_super_attack_id"
add_index "cards", ["type_id"], name: "index_cards_on_type_id"
create_table "cards_links", id: false, force: :cascade do |t|
t.integer "card_id"
t.integer "link_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "cards_links", ["card_id"], name: "index_cards_links_on_card_id"
add_index "cards_links", ["link_id"], name: "index_cards_links_on_link_id"
create_table "characters", force: :cascade do |t|
t.string "name"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "leader_skills", force: :cascade do |t|
t.string "name"
t.string "description"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "links", force: :cascade do |t| create_table "links", force: :cascade do |t|
t.string "name" t.string "name"
@ -20,6 +73,41 @@ ActiveRecord::Schema.define(version: 20151001151519) do
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
end end
create_table "medals", force: :cascade do |t|
t.string "name"
t.text "location"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "passive_skills", force: :cascade do |t|
t.string "name"
t.string "description"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "rarities", force: :cascade do |t|
t.string "name"
t.string "description"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "super_attacks", force: :cascade do |t|
t.string "name"
t.string "description"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "types", force: :cascade do |t|
t.string "name"
t.string "description"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "users", force: :cascade do |t| create_table "users", force: :cascade do |t|
t.string "provider" t.string "provider"
t.string "uid" t.string "uid"

View file

@ -1,7 +1,32 @@
# This file should contain all the record creation needed to seed the database with its default values. types = [
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). ['Physical', 'PHY', 'yellow'],
# ['Intellect', 'INT', 'purple'],
# Examples: ['Technique', 'TEQ', 'green'],
# ['Agility', 'AGL', 'blue'],
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) ['Strength', 'STR', 'red'],
# Mayor.create(name: 'Emanuel', city: cities.first) ]
rarities = [
['Normal', 'N'],
['Rare', 'R'],
['Super Rare', 'SR'],
['Super Super Rare', 'SSR'],
['Ultra Rare', 'UR'],
]
awaken_types = [
'Super',
'Extreme',
]
types.each do |description, name|
Type.create(name: name, description: description)
end
rarities.each do |description, name|
Rarity.create(name: name, description: description)
end
awaken_types.each do |name|
AwakenType.create(name: name)
end