2014-09-26 132 views
0

我在閱讀第3版ruby on rails教程的第7章時遇到了一個問題。ruby​​ on rails教程第7章問題顯示登錄頁

我想創建頁面登錄,並在嘗試顯示頁面時不斷收到錯誤消息。

這是錯誤消息

Showing /home/ubuntu/workspace/sample_app/app/views/layouts/application.html.erb where line #5 raised:

`Invalid CSS after "}": expected "}", was "" 
    (in /home/ubuntu/workspace/sample_app/app/assets/stylesheets/custom.css.scss:185) 
Extracted source (around line #5):` 

<html> <head> <title><%= full_title(yield(:title)) %></title> <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %> <%= javascript_include_tag "application", "data-turbolinks-track" => true %> <%= csrf_meta_tags %>

也運行耙測試時如下

{ERROR["test_should_get_new", UsersControllerTest, 0.379314557] 
test_should_get_new#UsersControllerTest (0.38s) 
ActionView::Template::Error:   ActionView::Template::Error: Invalid CSS after "}": expected  "}", was "" 
     (in /home/ubuntu/workspace/sample_app/app/assets/stylesheets/custom.css.scss:185) 
     app/assets/stylesheets/custom.css.scss:185 
     app/views/layouts/application.html.erb:5:in  `_app_views_layouts_application_html_erb__2473502046027579375_42591780' 
     test/controllers/users_controller_test.rb:5:in `block in <class:UsersControllerTest>' 
    app/assets/stylesheets/custom.css.scss:185 
    app/views/layouts/application.html.erb:5:in  `_app_views_layouts_application_html_erb__2473502046027579375_42591780' 
    test/controllers/users_controller_test.rb:5:in `block in <class:UsersControllerTest>' 

ERROR["test_layout_links", SiteLayoutTest, 0.432734702] 
test_layout_links#SiteLayoutTest (0.43s) 
ActionView::Template::Error:   ActionView::Template::Error: Invalid CSS after "}": expected  "}", was "" 
      (in /home/ubuntu/workspace/sample_app/app/assets/stylesheets/custom.css.scss:185) 
     app/assets/stylesheets/custom.css.scss:185 
     app/views/layouts/application.html.erb:5:in  `_app_views_layouts_application_html_erb__2473502046027579375_42591780' 
     test/integration/site_layout_test.rb:6:in `block in <class:SiteLayoutTest>' 
     app/assets/stylesheets/custom.css.scss:185 
    app/views/layouts/application.html.erb:5:in  `_app_views_layouts_application_html_erb__2473502046027579375_42591780' 
    test/integration/site_layout_test.rb:6:in `block in <class:SiteLayoutTest>' 

ERROR["test_invalid_signup_information", UsersSignupTest, 0.472730828] 
test_invalid_signup_information#UsersSignupTest (0.47s) 
ActionView::Template::Error:   ActionView::Template::Error: Invalid CSS after "}": expected  "}", was "" 
     (in /home/ubuntu/workspace/sample_app/app/assets/stylesheets/custom.css.scss:185) 
     app/assets/stylesheets/custom.css.scss:185 
     app/views/layouts/application.html.erb:5:in  `_app_views_layouts_application_html_erb__2473502046027579375_42591780' 
     test/integration/users_signup_test.rb:6:in `block in <class:UsersSignupTest>' 
    app/assets/stylesheets/custom.css.scss:185 
    app/views/layouts/application.html.erb:5:in  `_app_views_layouts_application_html_erb__2473502046027579375_42591780' 
    test/integration/users_signup_test.rb:6:in `block in <class:UsersSignupTest>' 

ERROR["test_should_get_about", StaticPagesControllerTest, 0.51867541] 
test_should_get_about#StaticPagesControllerTest (0.52s) 
ActionView::Template::Error:   ActionView::Template::Error: Invalid CSS after "}": expected  "}", was "" 
     (in /home/ubuntu/workspace/sample_app/app/assets/stylesheets/custom.css.scss:185) 
     app/assets/stylesheets/custom.css.scss:185 
     app/views/layouts/application.html.erb:5:in  `_app_views_layouts_application_html_erb__2473502046027579375_42591780' 
     test/controllers/static_pages_controller_test.rb:22:in `block in  <class:StaticPagesControllerTest>' 
    app/assets/stylesheets/custom.css.scss:185 
    app/views/layouts/application.html.erb:5:in  `_app_views_layouts_application_html_erb__2473502046027579375_42591780' 
    test/controllers/static_pages_controller_test.rb:22:in `block in  <class:StaticPagesControllerTest>' 

ERROR["test_should_get_contact", StaticPagesControllerTest, 0.773771717] 
test_should_get_contact#StaticPagesControllerTest (0.77s) 
ActionView::Template::Error:   ActionView::Template::Error: Invalid CSS after "}": expected  "}", was "" 
     (in /home/ubuntu/workspace/sample_app/app/assets/stylesheets/custom.css.scss:185) 
     app/assets/stylesheets/custom.css.scss:185 
     app/views/layouts/application.html.erb:5:in  `_app_views_layouts_application_html_erb__2473502046027579375_42591780' 
     test/controllers/static_pages_controller_test.rb:28:in `block in  <class:StaticPagesControllerTest>' 
    app/assets/stylesheets/custom.css.scss:185 
    app/views/layouts/application.html.erb:5:in  `_app_views_layouts_application_html_erb__2473502046027579375_42591780' 
     test/controllers/static_pages_controller_test.rb:28:in `block in  <class:StaticPagesControllerTest>' 

ERROR["test_should_get_help", StaticPagesControllerTest, 0.807242051] 
test_should_get_help#StaticPagesControllerTest (0.81s) 
ActionView::Template::Error:   ActionView::Template::Error: Invalid CSS after "}": expected  "}", was "" 
     (in /home/ubuntu/workspace/sample_app/app/assets/stylesheets/custom.css.scss:185) 
     app/assets/stylesheets/custom.css.scss:185 
     app/views/layouts/application.html.erb:5:in  `_app_views_layouts_application_html_erb__2473502046027579375_42591780' 
     test/controllers/static_pages_controller_test.rb:16:in `block in  <class:StaticPagesControllerTest>' 
    app/assets/stylesheets/custom.css.scss:185 
    app/views/layouts/application.html.erb:5:in  `_app_views_layouts_application_html_erb__2473502046027579375_42591780' 
    test/controllers/static_pages_controller_test.rb:16:in `block in  <class:StaticPagesControllerTest>' 

ERROR["test_should_get_home", StaticPagesControllerTest, 0.838956398] 
test_should_get_home#StaticPagesControllerTest (0.84s) 
ActionView::Template::Error:   ActionView::Template::Error: Invalid CSS after "}": expected "}", was "" 
     (in /home/ubuntu/workspace/sample_app/app/assets/stylesheets/custom.css.scss:185) 
     app/assets/stylesheets/custom.css.scss:185 
     app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb__2473502046027579375_42591780' 
     test/controllers/static_pages_controller_test.rb:10:in `block in  <class:StaticPagesControllerTest>' 
    app/assets/stylesheets/custom.css.scss:185 
    app/views/layouts/application.html.erb:5:in  `_app_views_layouts_application_html_erb__2473502046027579375_42591780' 
    test/controllers/static_pages_controller_test.rb:10:in `block in  <class:StaticPagesControllerTest>' 

    16/16: [========] 100% Time: 00:00:00, Time: 00:00:00 

Finished in 0.84354s 
16 tests, 17 assertions, 0 failures, 7 errors, 0 skips} 
01的錯誤消息

這是自定義sytle片

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

/* mixins, variables, etc. */ 

$gray-medium-light: #eaeaea; 

@mixin box_sizing { 
-moz-box-sizing: border-box; 
-webkit-box-sizing: border-box; 
box-sizing:   border-box; 
} 


    /* universal */ 

html { 
    overflow-y: scroll; 
    } 

body { 
    padding-top: 60px; 
} 

section { 
overflow: auto; 
} 

textarea { 
    resize: vertical; 
} 

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

/* typography */ 

h1, h2, h3, h4, h5, h6 { 
    line-height: 1; 
} 

h1 { 
font-size: 3em; 
letter-spacing: -2px; 
margin-bottom: 30px; 
    text-align: center; 
} 

h2 { 
    font-size: 1.2em; 
    letter-spacing: -1px; 
    margin-bottom: 30px; 
    text-align: center; 
    font-weight: normal; 
    color: $gray-light; 
} 

p { 
    font-size: 1.1em; 
    line-height: 1.7em; 
} 


/* header */ 

#logo { 
    float: left; 
    margin-right: 10px; 
    font-size: 1.7em; 
    color: white; 
    text-transform: uppercase; 
    letter-spacing: -1px; 
    padding-top: 9px; 
    font-weight: bold; 
    &:hover { 
    color: white; 
    text-decoration: none; 
    } 
} 

/* footer */ 

footer { 
    margin-top: 45px; 
    padding-top: 5px; 
    border-top: 1px solid $gray-medium-light; 
    color: $gray-light; 
    a { 
    color: $gray; 
    &:hover { 
     color: $gray-darker; 
    } 
    } 
    small { 
    float: left; 
    } 
    ul { 
    float: right; 
    list-style: none; 
    li { 
     float: left; 
     margin-left: 15px; 
    } 
    } 

/* miscellaneous */ 

.debug_dump { 
    clear: both; 
    float: left; 
    width: 100%; 
    margin-top: 45px; 
    @include box_sizing; 
} 

/* sidebar */ 

aside { 
    section.user_info { 
    margin-top: 20px; 
    } 
    section { 
    padding: 10px 0; 
    margin-top: 20px; 
    &:first-child { 
     border: 0; 
     padding-top: 0; 
    } 
    span { 
    display: block; 
     margin-bottom: 3px; 
     line-height: 1; 
    } 
    h1 { 
     font-size: 1.4em; 
     text-align: left; 
     letter-spacing: -1px; 
     margin-bottom: 3px; 
     margin-top: 0px; 
    } 
    } 
} 

.gravatar { 
    float: left; 
    margin-right: 10px; 
} 

.gravatar_edit { 
    margin-top: 15px; 
} 

/* forms */ 

input, textarea, select, .uneditable-input { 
    border: 1px solid #bbb; 
    width: 100%; 
    margin-bottom: 15px; 
    @include box_sizing; 
} 

input { 
    height: auto !important; 
} 

#error_explanation { 
    color: red; 
    ul { 
    color: red; 
    margin: 0 0 30px 0; 
    } 
} 

.field_with_errors { 
    @extend .has-error; 
    .form-control { 
    color: $state-danger-text; 
    } 
}` 

,這是application.html.erb文件

<!DOCTYPE html> 
<html> 
    <head> 
    <title><%= full_title(yield(:title)) %></title> 
    <%= stylesheet_link_tag "application", media: "all", 
               "data-turbolinks-track" => true %> 
    <%= javascript_include_tag "application", "data-turbolinks-track" => true %> 
    <%= csrf_meta_tags %> 
    <%= render 'layouts/shim' %> 
    </head> 
    <body> 
    <%= render 'layouts/header' %> 
    <div class="container"> 
    <% flash.each do |message_type, message| %> 
     <div class="alert alert-<%= message_type %>"><%= message %></div> 
     <% end %> 
     <%= yield %> 
     <%= render 'layouts/footer' %> 
    <%= debug(params) if Rails.env.development? %> 
    </div> 
    </body> 
</html> 

因爲章的最後已創建/設置其他網頁6都可以。

任何人都可以看到我的方式的錯誤?

回答

0

在你custom.css.scss:

ul { 
    float: right; 
    list-style: none; 
    li { 
     float: left; 
     margin-left: 15px; 
    } 
    } 
    } <--!!! 

你忘了關閉括號。

+0

這是原因。現在感到很傻 – 2014-09-26 15:26:40

相關問題