Ruby on Rails:simple_form + Twitter Bootstrap没有显示出来

我正在为我的网站上的新用户创建一个简单的sign_up表单。 我已经为simple_form bootstrap运行了安装…

rails g simple_form:install --bootstrap 

但是,它仍然没有显示和渲染为普通的simple_form。

这是我的表单代码:

 

Sign up

resource_name, :url => registration_path(resource_name ), :html => {:class => 'form-horizontal' }) do |f| %> true, class: "form-control"%> true, class: "form-control" %> true, class: "form-control" %> true, :autofocus => true, class: "form-control" %>

不知道我在这里做错了什么。 提前致谢。

这里的示例应用程序提到了如何单独下载Bootstrap(它们使用curl)并将其放在vendor / assets / stylesheets / bootstrap.css中。

请试试。

听起来好像您的应用程序中没有安装Bootstrap,或者您正在尝试使用Bootstrap 3.当我在2013-10-13上键入此内容时,Simple Form不支持​​Bootstrap 3.有关详细信息,请参阅此处 。

这意味着您需要将Bootstrap 2.x添加到您的应用程序中, Vidya已经提供了一些好的方向。

如果您有兴趣使用gem添加Bootstrap 2.x,那么我已经在下面提供了twitter-bootstrap-rails的说明。 如果我省略了什么,请务必查看他们的自述文件 。

在你的gemfile中添加:

 gem "twitter-bootstrap-rails", :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git' 

然后在rails控制台上进行项目运行(我假设你需要更少的支持):

 bundle install rails generate bootstrap:install less 

根据您是想要固定布局还是静态布局,请使用以下两行之一:

 rails g bootstrap:layout application fixed rails g bootstrap:layout application fluid 

最后,编辑您的application.css文件(在app / assets / stylesheets中找到),因此它’需要bootstrap_and_overrides类似于下面的示例:

 *= require_self *= require bootstrap_and_overrides *= require_tree . 

我很确定现在默认情况下会发生这种情况,但您可能还需要确认您的application.js中还需要twitter / bootstrap(可在app / assets / javascripts中找到)。 我的项目的一个例子如下:

 //= require jquery //= require jquery_ujs //= require twitter/bootstrap //= require turbolinks //= require_tree . 

如果它仍然不起作用,你添加了这个gem。 请告诉我你正在使用的ruby,rails,simple_form和twitter-bootstrap-rails的版本。