我正在使用bootstrap为css样式构建rails 5应用程序,并且在大多数情况下它一直正常工作。但是,出于某种原因,今天,当我在开发中使用localhost:3000时,只有html被渲染而没有我添加的任何引导样式。我知道这是一个相当笼统/模糊的问题,但是有没有理由为什么会这样呢?
以下是我最后一次运行的捆绑安装的输出:
Using rake 11.3.0
Using concurrent-ruby 1.0.2
Using i18n 0.7.0
Using minitest 5.9.1
Using thread_safe 0.3.5
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile2 2.1.0
Using rack 2.0.1
Using nio4r 1.2.1
Using websocket-extensions 0.1.2
Using mime-types-data 3.2016.0521
Using arel 7.1.4
Using execjs 2.7.0
Using bcrypt 3.1.11
Using sass 3.4.22
Using byebug 9.0.6
Using coffee-script-source 1.10.0
Using method_source 0.8.2
Using thor 0.19.1
Using debug_inspector 0.0.2
Using orm_adapter 0.5.0
Using unf_ext 0.0.7.2
Using ffi 1.9.14
Using multi_json 1.12.1
Using rb-fsevent 0.9.8
Using net-http-digest_auth 1.4
Using net-http-persistent 2.9.4
Using ntlm-http 0.1.1
Using webrobots 0.1.2
Using puma 3.6.0
Using bundler 1.13.6
Using ruby_http_client 3.0.0
Using tilt 2.0.5
Using sqlite3 1.3.12
Using turbolinks-source 5.0.0
Using tzinfo 1.2.2
Using nokogiri 1.6.8.1
Using rack-test 0.6.3
Using warden 1.2.6
Using sprockets 3.7.0
Using websocket-driver 0.6.4
Using mime-types 3.1
Using autoprefixer-rails 6.5.3
Using uglifier 3.0.3
Using font-awesome-sass 4.7.0
Using coffee-script 2.4.1
Using figaro 1.1.1
Using unf 0.1.4
Using rb-inotify 0.9.7
Using sendgrid-ruby 4.0.6
Using turbolinks 5.0.1
Using activesupport 5.0.0.1
Using loofah 2.0.3
Using mail 2.6.4
Using bootstrap-sass 3.3.7
Using domain_name 0.5.20161021
Using listen 3.0.8
Using rails-dom-testing 2.0.1
Using globalid 0.3.7
Using activemodel 5.0.0.1
Using jbuilder 2.6.0
Using spring 2.0.0
Using rails-html-sanitizer 1.0.3
Using http-cookie 1.0.3
Using activejob 5.0.0.1
Using activerecord 5.0.0.1
Using spring-watcher-listen 2.0.1
Using actionview 5.0.0.1
Using mechanize 2.7.5
Using actionpack 5.0.0.1
Using actioncable 5.0.0.1
Using actionmailer 5.0.0.1
Using railties 5.0.0.1
Using sprockets-rails 3.2.0
Using coffee-rails 4.2.1
Using responders 2.3.0
Using jquery-rails 4.2.1
Using material_icons 2.2.0
Using web-console 3.4.0
Using rails 5.0.0.1
Using sass-rails 5.0.6
Using devise 4.2.0
Bundle complete! 23 Gemfile dependencies, 83 gems now installed.
Gems in the group production were not installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
我的application.scss的起始行:
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
* files in this directory. Styles in this file should be added after the last require_* statement.
* It is generally better to create a new file per style scope.
*
*= require_tree .
*= require_self
*/
@import "bootstrap-sprockets";
@import "bootstrap";
@import "bootstrap/theme";
我的Gemfile的相关部分:
# For scraping
gem 'mechanize'
# Devise
gem 'devise'
# bootstrap
gem 'bootstrap-sass', '~> 3.3.6'
# font-awesome
gem 'font-awesome-sass', '~> 4.7.0'
# for environment variables
gem 'figaro'
# sendgrid
gem 'sendgrid-ruby'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platform: :mri
end
编辑:根据以下请求,我已在布局中添加了目标网页以及application.html.erb:
<% content_for :top_content do %>
<div class="jumbotron">
<div class="container">
<h1>Welcome!</h1>
<p class="center"> Some Content. We're currently in development - please contact us using the link below if you are interested in learning more. </p>
<p class="center">Register or Login to get started</p>
<p class="center">
<%= link_to 'Register', new_user_registration_path, class: 'btn btn-primary btn-lg' %>
<%= link_to 'Log In', new_user_session_path, class: 'btn btn-primary btn-lg' %>
</p>
</div>
</div>
<% end %>
Appliction.html.erb:
<!DOCTYPE html>
<html>
<head>
<title>TITLE</title>
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>
<body>
<%= render 'layouts/header' %>
<div class="container">
<% flash.each do |key, value| %>
<div class="alert alert-<%= key %>">
<%= value %>
</div>
<% end %>
</div>
<%= yield :top_content %>
<div class="container">
<h1><%= yield :header %></h1>
<%= yield %>
</div>
<div class = "container">
<%= render 'layouts/footer' %>
</div>
</body>
</html>