2015-04-05 145 views
0

我是Rails的新手,并且通过一个(不太好)的教程,但是我被Rails管道阻塞了。Rails not loading bootstrap

我将gem bootstrap-sass添加到我的Gemfile中,然后运行(从我的Rails应用程序的根目录)bin/bundle install

$ bin/bundle show bootstrap-sass 

出现以下响应,所以我假设自举萨斯安装

$ /Users/cosette/.rvm/gems/ruby-2.1.2/gems/bootstrap-sass-3.2.0.2 

我修改app/assets/stylesheets/application.css所以它看起来像:

/* 
    * [boilerplate text generated by rails] 
    * 
    *= require_tree . 
    *= require bootstrap 
    *= require_self 
    */ 

现在,如果我开始up bin/rails server

=> Booting WEBrick 
=> Rails 4.2.1 application starting in development on http://localhost:3000 
=> Run `rails server -h` for more startup options 
=> Ctrl-C to shutdown server 
[2015-04-05 15:30:08] INFO WEBrick 1.3.1 
[2015-04-05 15:30:08] INFO ruby 2.1.2 (2014-05-08) [x86_64-darwin13.0] 
[2015-04-05 15:30:08] INFO WEBrick::HTTPServer#start: pid=3904 port=3000 

并将我的网络浏览器指向http://localhost:3000/posts,我得到Sprockets::FileNotFound in Posts#index。这是Rails的控制台输出:

Started GET "/posts" for ::1 at 2015-04-05 15:31:03 -0400 
    ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations" 
Processing by PostsController#index as HTML 
    Post Load (0.6ms) SELECT "posts".* FROM "posts" 
    User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 1]] 
    CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 1]] 
    Rendered collection (38.1ms) 
    Rendered posts/index.html.erb within layouts/application (65.2ms) 
Completed 500 Internal Server Error in 124ms (ActiveRecord: 1.9ms) 

ActionView::Template::Error (couldn't find file 'bootstrap' 
    (in /Users/cosette/Documents/workspace/rails/code/social/app/assets/stylesheets/application.css:14)): 
    2: <html> 
    3: <head> 
    4: <title>Social</title> 
    5: <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> 
    6: <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> 
    7: <%= csrf_meta_tags %> 
    8: </head> 
    app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb__2483101853858498351_70166979821380' 

有谁知道如何得到这个工作?谢谢。

回答

2

根据documentation需要引导的SaaS宝石:

  • 重命名像application.css文件application.scss
  • 进口自举文件: @import "bootstrap-sprockets"; @import "bootstrap";

希望这有助于

+0

还删除所有'* = require xyz'指令。 – jay 2015-04-06 01:26:56