1
0
Fork 0

Use symbols for day_types

This commit is contained in:
Andrew Tomaka 2013-08-11 13:40:44 -04:00
parent 9f260a691c
commit 966f734aa0
2 changed files with 11 additions and 3 deletions

View File

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

View File

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