parent
f5bdb92a2a
commit
40770d4240
@ -1,7 +1,11 @@
|
|||||||
class Creature < ApplicationRecord
|
class Creature < ApplicationRecord
|
||||||
scope :alive, -> { where('health_points > 0') }
|
scope :alive, -> { where('health_points > 0') }
|
||||||
|
|
||||||
|
enum :size, [:small, :big, :giant]
|
||||||
|
|
||||||
def to_label
|
def to_label
|
||||||
"#{name} (#{health_points})"
|
"#{name} (#{health_points})"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
class AddSizeColumnToCreatures < ActiveRecord::Migration[7.0]
|
||||||
|
def change
|
||||||
|
add_column :creatures, :size, :integer
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in new issue