[英]Rails simple_form + Bootstrap not working
In my Rails project I have bootstrap-sass (3.3.6, 3.3.4.1) installed. 在我的Rails项目中,我安装了bootstrap-sass(3.3.6,3.3.4.1)。 I also added @import "bootstrap";
我还添加了@import "bootstrap";
to my application.css.scss
. 到我的application.css.scss
。
Now I am able to use Bootstrap classes in my project just fine. 现在,我可以在项目中使用Bootstrap类了。
Now I want to use Bootstrap by default on all forms. 现在,我想在所有表单上默认使用Bootstrap。 So I added the gem and installed simple_form 所以我添加了gem并安装了simple_form
rails generate simple_form:install --bootstrap
From what I understand this form here should now be displayed with Bootstrap styles, but it doesn't 据我了解,此表单现在应该以Bootstrap样式显示,但它不
<section class="content">
<div class="box">
<div class="box-body">
<%= simple_form_for :ride, url: order_path do |f| %>
<p>
<%= f.label :client %><br>
<%= f.text_field :client %>
</p>
<p>
<%= f.submit 'Adicionar', :class => 'btn btn-primary' %>
</p>
<% end %>
</div>
</div>
</section>
The button gets styled since I am adding the classes manually, but the input fields don't. 自从我手动添加类以来,按钮的样式已设置,但输入字段未设置。 I added the code that wraps this form, just to make sure to be complete. 我添加了包装此表单的代码,以确保完整。
Anyone an idea on what I am doing wrong? 有人知道我在做什么错吗?
Its possible that the default version of simple_form is not completely working with Bootstrap 3. try to change the simple_form gem to 默认版本的simple_form可能无法完全与Bootstrap 3配合使用。尝试将simple_form gem更改为
gem 'simple_form', '~> 3.1.0.rc1', github: 'plataformatec/simple_form', branch: 'master'
or 要么
gem 'simple_form', '~> 3.2', '>= 3.2.1'
and then restart the rails server and see if it works. 然后重新启动Rails服务器,看看它是否有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.