From the course: Ruby on Rails 5 Essential Training

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Date and time form helpers

Date and time form helpers - Ruby on Rails Tutorial

From the course: Ruby on Rails 5 Essential Training

Start my 1-month free trial

Date and time form helpers

- [Instructor] Rails has select-option form helpers which are specially designed for working with dates and times. It can be extremely tedious to take a date and a time, and to break it up on a form into five or six different select-option tags. Then you have to generate the options for each one of those and then determine which of those options should be currently selected. Then once the form has been submitted, you would need to take all of those parameters and reassemble them back into a date. Fortunately, the Rails Helpers make this process much easier. We're going to look at the three main Helpers. The first of which is date_select. Date_select works just like select did, but it will generate three different select-option tags in a row: one for year, one for month, and one for day. We don't have to pass in choices like we did with the select helper, because Rails knows what choices to offer. The choices are going to be dates, and the helper knows how dates work. It knows the…

Contents