diff --git a/app/models/card.rb b/app/models/card.rb index b88c758..8ffd81d 100644 --- a/app/models/card.rb +++ b/app/models/card.rb @@ -1,6 +1,8 @@ class Card < ActiveRecord::Base has_paper_trail + before_save :set_stat_types + belongs_to :character belongs_to :rarity belongs_to :type @@ -46,4 +48,12 @@ class Card < ActiveRecord::Base def icon "card_#{gameid}_thumb.png" end + + private + + def set_stat_types + self.hp_stat.stat_type_id = 1 + self.atk_stat.stat_type_id = 2 + self.def_stat.stat_type_id = 3 + end end diff --git a/app/views/admin/cards/_form.html.slim b/app/views/admin/cards/_form.html.slim index 2d99998..aef3d73 100644 --- a/app/views/admin/cards/_form.html.slim +++ b/app/views/admin/cards/_form.html.slim @@ -29,41 +29,41 @@ .col-md-12 = f.label 'Health Points' .row - = f.simple_fields_for :hp_stat do |hp| + = f.simple_fields_for :hp_stat do |h| .col-md-3 - = hp.input :min + = h.input :min .col-md-3 - = hp.input :max + = h.input :max .col-md-3 - = hp.input :awaken_min + = h.input :awaken_min .col-md-3 - = hp.input :awaken_max + = h.input :awaken_max .row .col-md-12 = f.label 'Attack' .row - = f.simple_fields_for :atk_stat do |hp| + = f.simple_fields_for :atk_stat do |a| .col-md-3 - = hp.input :min + = a.input :min .col-md-3 - = hp.input :max + = a.input :max .col-md-3 - = hp.input :awaken_min + = a.input :awaken_min .col-md-3 - = hp.input :awaken_max + = a.input :awaken_max .row .col-md-12 = f.label 'Defense' .row - = f.simple_fields_for :def_stat do |hp| + = f.simple_fields_for :def_stat do |d| .col-md-3 - = hp.input :min + = d.input :min .col-md-3 - = hp.input :max + = d.input :max .col-md-3 - = hp.input :awaken_min + = d.input :awaken_min .col-md-3 - = hp.input :awaken_max + = d.input :awaken_max .row .col-md-12 = f.label :links