4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[Rails]date_selectにBootstrapのform-controlが適用されない

Last updated at Posted at 2021-01-12

#課題
Rails + Boostrap でdate_selectにform-controlが適用されない

_form.html.erb
<%= form.date_select :date, class: "form-control" %>

スクリーンショット 2021-01-12 8.53.42.png

#結論
以下のような書き方で適用されます。

_form.html.erb
<%= form.date_select :date, {}, {class: 'form-control', style: 'display: inline-block;width: auto;'} %>

スクリーンショット 2021-01-12 8.56.37.png

ちなみにこの style: 'display: inline-block;width: auto; をサボると想定外にダッさい表示になります。

スクリーンショット 2021-01-12 8.58.41.png

地味に初学者が躓くので再度メモしました。
技術背景も含めて以下記事が完全回答版です。
過去の先人たちに感謝いたします。

#参考情報
Rails date_selectをBootstrapを使っていい感じにする
https://qiita.com/t_oginogin/items/519fb52e1708e26a8b73

4
1
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
4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?