2016-12-06 155 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爲我提供了我的解決方案。感謝大家誰幫助我在這篇文章,這是非常感謝和一個偉大的學習經驗:)