Use symbols for day_types
This commit is contained in:
parent
9f260a691c
commit
966f734aa0
2 changed files with 11 additions and 3 deletions
|
@ -1,5 +1,13 @@
|
||||||
class Workout < ActiveRecord::Base
|
class Workout < ActiveRecord::Base
|
||||||
DAY_TYPES = %w(heavy medium light)
|
DAY_TYPES = [:heavy, :medium, :light ]
|
||||||
validates_date :date
|
validates_date :date
|
||||||
validates_inclusion_of :day_type, :in => Workout::DAY_TYPES
|
validates_inclusion_of :day_type, :in => Workout::DAY_TYPES
|
||||||
|
|
||||||
|
def day_type
|
||||||
|
read_attribute(:day_type).to_sym
|
||||||
|
end
|
||||||
|
|
||||||
|
def day_type=(value)
|
||||||
|
write_attribute(:day_type, value.to_s)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<%= f.label :day_type %>
|
<%= f.label :day_type %>
|
||||||
<%= f.select :day_type, [["Heavy", 'heavy'], ["Medium", 'medium'],
|
<%= f.select :day_type, [["Heavy", :heavy], ["Medium", :medium],
|
||||||
["Light", 'light']] %>
|
["Light", :light]] %>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<%= f.label :comment %>
|
<%= f.label :comment %>
|
||||||
|
|
Loading…
Reference in a new issue