我正在关注此tutorial
但是登录和注册页面的引导程序没有加载。只是我得到了上标题。我不明白为什么会这样....我已经正确地遵循了教程。引导程序有一些问题
[application.html.erb]
<!DOCTYPE html>
<html>
<head>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>
<nav class="navbar navbar-inverse">
<div class="container">
<div class="navbar-header">
<%= link_to 'Clear Sky', root_path, class: 'navbar-brand' %>
</div>
<div id="navbar">
<% if signed_in? %>
<ul class="nav navbar-nav">
<li><%= link_to 'Add Page', new_page_path %></li>
</ul>
<% end %>
<ul class="nav navbar-nav pull-right">
<% if signed_in? %>
<li><span><%= current_user.email %></span></li>
<li><%= link_to 'Sign out', sign_out_path, method: :delete %></li>
<% else %>
<li><%= link_to 'Sign in', sign_in_path %></li>
<% end %>
</ul>
</div>
</div>
</nav>
<div class="container">
<% flash.each do |key, value| %>
<div class="alert alert-<%= key %>">
<%= value %>
</div>
<% end %>
<%= yield %>
<div id="footer">
<div class="container-fluid">
</div>
</div>
</div>
</body>
</html>
[pages_Controller]
class PagesController < ApplicationController
before_action :require_login, only: [:new]
def index
end
def new
end
end
[宝石文件]
gem 'rails', '4.2.5'
# Use sqlite3 as the database for Active Record
gem 'pg'
gem 'bootstrap-sass','~> 3.3.5'
gem 'clearance', '~> 1.11'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
[application.scss]
@import 'bootstrap-sprockets';
@import 'bootstrap';
.navbar-nav > li > span {
padding-bottom: 15px;
padding-top: 15px;
color: #9d9d9d;
line-height: 20px;
display: block;
}
#footer {
margin-top: 50px;
}
.other-links {
margin-top: 10px;
}
[的application.js]
// 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 any plugin's vendor/assets/javascripts directory 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.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
答案 0 :(得分:0)
尝试在javascripts / aplication.js中添加//= require bootstrap-sprockets
,看看它是否有效。
//= require jquery
//= require jquery_ujs
//= require jquery.turbolinks
//= require bootstrap-sprockets
//= require turbolinks
//= require_tree .
我也建议使用偏。所以很容易阅读。例如:
您可以在_navbar.html.erb
文件夹中创建名为layouts
的文件,然后将所有代码导航栏粘贴到其中。
<%= render 'layouts/navBar' %>
<!-- Flash Errors -->
<%= render 'layouts/flashErrors' %>
<%= yield %>
<%= render 'layouts/footer' %>
更具可读性...啦啦队友!