Created
October 22, 2013 02:02
-
-
Save zackfern/7094106 to your computer and use it in GitHub Desktop.
Helper method for parsing the output from date_select fields.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Public: Parse values from Rails date_select form helper. | |
# | |
# dsv - Stands for Date Select Values. Pass in whatever hash | |
# contains the attributes of the date_select box. | |
# name - Name of the Date Select. For example, if your params | |
# contain 'date_of_birth(2i)' then your name would be | |
# 'date_of_birth' (which happens to be the default) | |
# | |
# Returns a Date object. | |
def parse_date_select_values(dsv, name='date_of_birth') | |
Date.new dsv["#{name}(1i)"].to_i, dsv["#{name}(2i)"].to_i, dsv["#{name}(3i)"].to_i | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment