[RUBY] [Rails] Bootstrap form-control does not apply to date_select

Task

Rails + Boostrap does not apply form-control to date_select

erb:_form.html.erb


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

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

Conclusion

It is applied in the following writing style.

erb:_form.html.erb


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

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

By the way, if you skip this style:'display: inline-block; width: auto ;, the display will be unexpectedly dull.

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

I made a note again because the beginners stumbled on it. The following article, including the technical background, is the complete answer version. Thank you to our past ancestors.

Reference information

Make Rails date_select feel good with Bootstrap https://qiita.com/t_oginogin/items/519fb52e1708e26a8b73

Recommended Posts

[Rails] Bootstrap form-control does not apply to date_select
Introducing Bootstrap to Rails 5
Introducing Bootstrap to Rails !!
How to deploy Bootstrap on Rails
[Rails] What to do when rails s does not respond or does not stop
[Rails] Video does not play with video_tag
JavaScript (vanilla) does not respond in Rails.
[Rails] [Memo] When to add = to <%%> and when not
What to do when rails db: seed does not reflect in the database
Ruby's "1101" .to_i (2) does not convert decimal numbers to decimal numbers.
Apply Twitter Bootstrap 4 to Spring Boot 2 using Webjars
[Rails] Added in devise: username not added to database
[Ruby on Rails] How to install Bootstrap in Rails
Automatically apply bootstrap style to devise view files
What to do if the update does not take effect after deploying Rails AWS
Rails Bootstrap introduced
Bundle install with docker + rails6 does not reflect gem
When the server does not start with rails s
What to do when Rails on Docker does not reflect controller changes in the browser