web制作をしてて日付や時刻を入力するためのフォームを作ることがよくある。 Railsには年月日時分を自動的に作成してくれるヘルパーメソッドがある。今まで知らずに地道にドロップダウンリストを作成してしまっていた。。 便利なのでまとめておく。 4つのヘルパーメソッドがある モデルに対応したフォーム 単純な入力項目 日付のみ date_select select_date 日時も含む datetime_select select_datetime 使い方 date_select(object_name, method, options = {}, html_options = {}) datetime_select(object_name, method, options = {}, html_options = {}) select_date(date = Date.current, opt
![Railsで日付・時刻を入力するためのフォームを簡単に作る方法まとめ - 久保清隆のブログ](https://cdn-ak-scissors.b.st-hatena.com/image/square/24b219bff05b9774929ca2577680f8ddd09574a4/height=288;version=1;width=512/http%3A%2F%2Fecx.images-amazon.com%2Fimages%2FI%2F41qXc1dvs-L.jpg)