From e0c8c56dbd11e4cefb2ab2353da4586ee862832b Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Thu, 8 Oct 2015 11:45:05 -0400 Subject: [PATCH] Add dokkan card --- app/controllers/cards_controller.rb | 2 +- app/models/card.rb | 12 ++++++++++-- app/views/cards/_form.html.slim | 3 +++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/controllers/cards_controller.rb b/app/controllers/cards_controller.rb index 6bd6325..75dcd5b 100644 --- a/app/controllers/cards_controller.rb +++ b/app/controllers/cards_controller.rb @@ -45,7 +45,7 @@ class CardsController < ApplicationController 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: []) + :awaken_type_id, :dokkan_id, link_ids: []) end def set_card diff --git a/app/models/card.rb b/app/models/card.rb index 71a40fe..fcb87d8 100644 --- a/app/models/card.rb +++ b/app/models/card.rb @@ -6,7 +6,7 @@ class Card < ActiveRecord::Base belongs_to :passive_skill belongs_to :super_attack belongs_to :awaken_type - has_one :dokkan_card, class_name: 'Card', foreign_key: :dokkan_id + belongs_to :dokkan_card, class_name: 'Card', foreign_key: :dokkan_id has_and_belongs_to_many :links @@ -22,6 +22,14 @@ class Card < ActiveRecord::Base validates :awaken_type, presence: true def dokkan? - self.dokkan_id != nil + dokkan_id != nil + end + + def full_name + "#{prefix} #{character.name}" + end + + def icon + "card_#{gameid}_thumb.png" end end diff --git a/app/views/cards/_form.html.slim b/app/views/cards/_form.html.slim index e50bc1f..e30cee1 100644 --- a/app/views/cards/_form.html.slim +++ b/app/views/cards/_form.html.slim @@ -22,6 +22,9 @@ .row .col-md-6 = f.association :super_attack + .row + .col-md-6 + = f.association :dokkan_card, label_method: :full_name .row .col-md-12 = f.label :links