I have the following view code:
<%= f.select :day_of_play, Team::DAYS_OF_WEEK %>
And I have to create the following map for it to work and display a select box:
DAYS_OF_WEEK = {"Sunday" => 0,
"Monday"=> 1,
"Tuesday"=> 2,
"Wednesday"=>3,
"Thursday"=>4,
"Friday"=> 5,
"Saturday"=>6,
}
I store the integer in the database, but then when I display the integer it seems backwards that I have to create another map in order to go from integer->to->Saturday?
What am I doing wrong and how should I implement this correctly, soit is the dry principle?
If you want to adhere to the DRY principle, I recommend using
Date::DAYNAMES.E.g. like this: