Module: DateParams::ControllerAdditions::ClassMethods
- Defined in:
- lib/date_params/controller_additions.rb
Instance Method Summary collapse
-
#date_params(*args) ⇒ Object
Converts a text field with a date, in a specified format, into a Date object.
-
#datetime_params(*args) ⇒ Object
Similar to #date_params, but parses a date input field and a time input field and combines them into a new timezone-aware datetime field.
Instance Method Details
#date_params(*args) ⇒ Object
Converts a text field with a date, in a specified format, into a Date object
9 10 11 12 13 14 |
# File 'lib/date_params/controller_additions.rb', line 9 def date_params(*args) = args. before_filter do |controller| args.each { |param| DateParams::Parser.new(param, , controller.params).parse_date_param! } end end |
#datetime_params(*args) ⇒ Object
Similar to #date_params, but parses a date input field and a time input field and combines them into a new timezone-aware datetime field.
18 19 20 21 22 23 |
# File 'lib/date_params/controller_additions.rb', line 18 def datetime_params(*args) = args. before_filter do |controller| args.each { |param| DateParams::Parser.new(param, , controller.params).parse_datetime_param! } end end |