2013-12-21 65 views
0

我對RoR非常陌生,並且一直遵循Michael Hartl的教程,現在已經停留在引入Bootstrap框架的部分。所有的寶石正在更新和安裝。bootstrap似乎沒有導入

語言環境/ application.rb中

require File.expand_path('../boot', __FILE__) 

# Pick the frameworks you want: 
require "active_record/railtie" 
require "action_controller/railtie" 
require "action_mailer/railtie" 
require "sprockets/railtie" 
# require "rails/test_unit/railtie" 

# Require the gems listed in Gemfile, including any gems 
# you've limited to :test, :development, or :production. 
Bundler.require(:default, Rails.env) 

module SampleApp 
    class Application < Rails::Application 
    # Settings in config/environments/* take precedence over those specified here. 
    # Application configuration should go into files in config/initializers 
    # -- all .rb files in that directory are automatically loaded. 

    # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. 
    # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. 
    # config.time_zone = 'Central Time (US & Canada)' 

    # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. 
    # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] 
    # config.i18n.default_locale = :de 
    config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif) 
    end 
end 

application.html.erb

<!DOCTYPE html> 
<html> 
    <head> 
    <title><%= full_title(yield(:title)) %></title> 
    <%= stylesheet_link_tag "default", media: "all", "data-turbolinks-track" => true %> 
    <%= javascript_include_tag "default", "data-turbolinks-track" => true %> 
    <%= csrf_meta_tags %> 
    <%= render 'layouts/shim' %> 
    </head> 
    <body> 
    <%= render 'layouts/header' %> 
    <div class="container"> 
     <%= yield %> 
     <%= render 'layouts/footer' %> 
    </div> 
    </body> 
</html> 

home.html.erb

<% provide(:title, 'Home') %> 

<div class="center hero-unit"> 
<h1>Welcome to the Sample App</h1> 

<h2> 
    This is the home page for the 
    <a href="http://railstutorial.org/">Ruby on Rails Tutorial</a> 
    sample application. 
</h2> 

<%= link_to "Sign up now!", '#', class: "bttn btn-large btn-primary" %> 
</div> 

<%= link_to image_tag("rails.png", alt: "Rails"), 'http://rubyonrails.org/' %> 

custom.css.scss

@import "bootstrap"; 

/* universal */ 

html { 
    overflow-y: scroll; 
} 

border-style: { 
    padding-top: 60px; 
} 

section { 
    overflow:auto; 
} 

textarea { 
    resize: vertical; 
} 

.center { 
    text-align: center; 
} 

.center h1 { 
    margin-bottom: 10px; 
} 

我收集的東西很可能是不正確的,因爲/home.html.erb的源代碼沒有對/styles/bootscrap.css進行任何引用。我應該有一個bootstrap.css文件以及其他樣式表嗎?如果是這樣的話,在嘖嘖中沒有提到。

<head> 
    <title>Ruby on Rails Tutorial Sample App | Home</title> 
    <link data-turbolinks-track="true" href="/stylesheets/default.css" media="all" rel="stylesheet" /> 
    <script data-turbolinks-track="true" src="/javascripts/default.js"></script> 
    <meta content="authenticity_token" name="csrf-param" /> 
<meta content="n2QVul+/didf2xA6jj3QelpDZdOrUpgaWcDp1XFQACM=" name="csrf-token" /> 
    <!--[if lt IE 9]> 
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> 
<! [endif] 

這是什麼/ static_pages /家都看起來像是對我來說: ​​

與一個從教程:tutorial home 我想不出什麼別的包括但如果我錯過了一些東西,我一定會很快跟進。謝謝!

回答

0

在application.html.erb, 它應該是「應用程序」,而不是「默認」。

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

https://github.com/railstutorial/sample_app_rails_4/blob/master/app/views/layouts/application.html.erb

+0

謝謝。我一直在閱讀噸堆棧和噸堆棧的不同問題/答案,這是我認爲我會嘗試的建議之一。經過幾分鐘的指導github教程,並跟蹤錯誤線索,我認爲我有事情的工作。有時需要另一套眼睛。 – user3124577