1
0
Fork 0

Set stat_type correctly

This commit is contained in:
Andrew Tomaka 2015-10-21 09:27:49 -04:00
parent faa1f56aec
commit ea38a64ced
2 changed files with 25 additions and 15 deletions

View file

@ -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

View file

@ -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