以下命令将simple_form与twitter-bootstrap
集成在一起$ rails g simple_form:install --bootstrap
identical config/initializers/simple_form.rb
create config/initializers/simple_form_bootstrap.rb
exist config/locales
identical config/locales/simple_form.en.yml
identical lib/templates/erb/scaffold/_form.html.erb
===============================================================================
Be sure to have a copy of the Bootstrap stylesheet available on your
application, you can get it on http://twitter.github.com/bootstrap.
Inside your views, use the 'simple_form_for' with one of the Bootstrap form
classes, '.form-horizontal', '.form-inline', '.form-search' or
'.form-vertical', as the following:
= simple_form_for(@user, html: {class: 'form-horizontal' }) do |form|
===============================================================================
但我想将simple_form与 bootstrap 3 集成。这个命令用的是什么?
答案 0 :(得分:3)
让Bootstrap 3与SimpleForm一起正常工作有点棘手,但是这个页面上的说明对我来说非常好,几乎是逐字的:
Using Twitter Bootstrap 3 with simple_form
(我正在使用Rails 3.2,但我认为它们对Rails 4同样有效.YMMV。)
以下是关键点:
simple_form.rb
添加到col-lg-2
声明config.label_class
初始值设定项
simple_form_bootstrap.rb
初始化程序,方法是将“control-group”的所有实例(3)更改为“form-group”,并将“control”的所有实例(3)更改为“col-lg-10”< / LI>
当然,不要忘记重启rails服务器以获取更改。