在我安装了bootstrap
gem并rails server
再次运行后,我收到此错误:
NoMethodError in Pages#welcome undefined method `environment' for nil:NilClass (in /Users/neilpatel/Desktop/Rails/prospects/app/assets/stylesheets/custom.css.scss)
@import "bootstrap";
Prospects <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %> <%= javascript_include_tag "application", "data-turbolinks-track" => true %> <%= csrf_meta_tags %> <%= link_to "Home", "/" %> <%= link_to "About", "/about" %> <%= yield %>
Processing by PagesController#welcome as HTML Rendered pages/welcome.html.erb within layouts/application (0.1ms) Completed 500 Internal Server Error in 15ms ActionView::Template::Error (undefined method `environment' for nil:NilClass (in /Users/neilpatel/Desktop/Rails/prospects/app/assets/stylesheets/custom.css.scss)): 4: 5:Prospects 6: 7: <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %> 8: <%= javascript_include_tag "application", "data-turbolinks-track" => true %> 9: 10: <%= csrf_meta_tags %> app/views/layouts/application.html.erb:7:in `_app_views_layouts_application_html_erb___3923576615849785590_70354614228980'
source 'https://rubygems.org' gem 'rails', '4.0.0.rc1' gem 'sqlite3' gem 'sass-rails', '~> 4.0.0.rc1' gem 'uglifier', '>= 1.3.0' gem 'coffee-rails', '~> 4.0.0' gem 'jquery-rails' gem 'turbolinks' gem 'jbuilder', '~> 1.0.1' gem 'bootstrap-sass', '~> 3.1.1' group :doc do # bundle exec rake doc:rails generates the API under doc/api. gem 'sdoc', require: false end
// This is a manifest file that'll be compiled into application.js, which will include all the files // listed below. // // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. // // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the // compiled file. // // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD // GO AFTER THE REQUIRES BELOW. // //= require jquery //= require jquery_ujs //= require bootstrap //= require turbolinks //= require_tree .
更新了gemfile运行包更新
'ran bundle update Bundler could not find compatible versions for gem "railties": In Gemfile: sass-rails (~> 4.0.2) ruby depends on railties (< 5.0, >= 4.0.0) ruby rails (= 4.0.0.rc1) ruby depends on railties (4.0.0.rc1)
DMKE.. 7
这是sass-rails
宝石如何与sprockets
Sprockets v2.11.1版本之后浮现的宝石集成的问题(参见此处和此处).
要修复它,请更改Gemfile:
gem 'sass-rails', '~> 4.0.2'
并运行bundle update
.
注意:您还应该更新您的Rails版本.最新版本是v4.0.4.为此,请将Gemfile更改为
gem 'rails', '~> 4.0.0'
再次,跑bundle update
.
这是sass-rails
宝石如何与sprockets
Sprockets v2.11.1版本之后浮现的宝石集成的问题(参见此处和此处).
要修复它,请更改Gemfile:
gem 'sass-rails', '~> 4.0.2'
并运行bundle update
.
注意:您还应该更新您的Rails版本.最新版本是v4.0.4.为此,请将Gemfile更改为
gem 'rails', '~> 4.0.0'
再次,跑bundle update
.