2016-12-06 151 views
0

大家好我已经为我的应用程序安装了引导程序,但它工作得不好。这是我的application.scss文件Bootstrap导轨无法正常工作

@import "bootstrap-sprockets"; 
@import "bootstrap"; 

这里是我的application.rb中的文件:

<!DOCTYPE html> 
<html> 
    <head> 
    <title>BootstrapApp</title> 

    <%= stylesheet_link_tag 'default', media: 'all', 'data-turbolinks-track' => true%> 
    <%= javascript_include_tag 'default', 'data-turbolinks-track' => true %> 
    <%= csrf_meta_tags %> 
    </head> 

    <body> 
     <%= yield %> 
    </body> 
</html> 

的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. JavaScript code in this file should be added after the last require_* statement. 
// 
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details 
// about supported directives. 
// 
//= require jquery 
//= require jquery_ujs 
//= require bootstrap-sprockets 
//= require turbolinks 
//= require_tree . 

最后这里是我的宝石文件:

source 'http://rubygems.org' 

gem 'bootstrap-sass', '~> 3.3.5' 

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 
gem 'rails', '~> 5.0.0', '>= 5.0.0.1' 
# Use sqlite3 as the database for Active Record 
gem 'sqlite3' 
# Use Puma as the app server 
gem 'puma', '~> 3.0' 
# Use SCSS for stylesheets 
gem 'sass-rails', '~> 5.0' 
# Use Uglifier as compressor for JavaScript assets 
gem 'uglifier', '>= 1.3.0' 
# Use CoffeeScript for .coffee assets and views 
gem 'coffee-rails', '~> 4.2' 
# See https://github.com/rails/execjs#readme for more supported runtimes 
# gem 'therubyracer', platforms: :ruby 

# Use jquery as the JavaScript library 
gem 'jquery-rails' 
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 
gem 'turbolinks', '~> 5' 
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 
gem 'jbuilder', '~> 2.5' 
# Use Redis adapter to run Action Cable in production 
# gem 'redis', '~> 3.0' 
# Use ActiveModel has_secure_password 
# gem 'bcrypt', '~> 3.1.7' 

# 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 

group :development do 
    # Access an IRB console on exception pages or by using <%= console %> anywhere in the code. 
    gem 'web-console' 
end 

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 

这里是我得到磨片ñ试图将导航栏添加到我的网页:

enter image description here

+0

你是否得到任何错误?如果是,请发布错误消息? –

+0

不,我没有收到任何错误消息,只是当我进入我的索引页时,文本只是普通的html,没有bootstrap引导程序,我应该能够看到文本中的变化no? – Aaron

+0

从application.scss/css中删除bootstrap-sprockets。 – Milind

回答

1

问题是,你不需要application.scssapplication.js

<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true%> 
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> 

如果你所得到的Object does not support the property or method错误,则使用最新的创业板“咖啡脚本代码”(如1.10.0) - 比版本1.9.x中的任何其他

以下行添加到Gemfile,运行bundle install并重新启动服务器。

gem 'coffee-script-source', '~> 1.11', '>= 1.11.1' 
+0

还是......安装此之后。它给我同样的确切的错误:( – Aaron

+0

@Aaron你应该尝试[这个]的第一个答案(http://stackoverflow.com/questions/28312460/object-doesnt-support-this-property-or-method-rails -windows-64bit)的问题,它有点脏,但应该工作。 –

0

我终于得到了这个工作。 this link为我提供了我的解决方案。感谢大家谁帮助我在这篇文章,这是非常感谢和一个伟大的学习经验:)