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
|
||||
DAY_TYPES = %w(heavy medium light)
|
||||
DAY_TYPES = [:heavy, :medium, :light ]
|
||||
validates_date :date
|
||||
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
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
</div>
|
||||
<div>
|
||||
<%= f.label :day_type %>
|
||||
<%= f.select :day_type, [["Heavy", 'heavy'], ["Medium", 'medium'],
|
||||
["Light", 'light']] %>
|
||||
<%= f.select :day_type, [["Heavy", :heavy], ["Medium", :medium],
|
||||
["Light", :light]] %>
|
||||
</div>
|
||||
<div>
|
||||
<%= f.label :comment %>
|
||||
|
|
Loading…
Reference in a new issue