0
0

More than 3 years have passed since last update.

Ruby 5 erbファイルのフォームのdate_select オプションの書き方

Posted at

オプション指定の書き方だけで30分くらいハマったので,記録します.
あと,けっこうググってもなかなかわからなかった.

環境

Ruby version: RUBY VERSION: 2.6.3
Rails version: Rails 5.0.7.2

date_select オプションの書き方

カラム(ここでは:release_date)の後ろの{}内にオプションを書く.

new.html.erb
<%= f.date_select :release_date, {start_year: 1900, end_year: (Time.now.year)},class: 'form-control' %>

参考

https://rails.densan-labs.net/form/datetime_register_form.html
https://api.rubyonrails.org/v5.1.7/classes/ActionView/Helpers/DateHelper.html#method-i-date_select

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0