当我加载root时,标题显示和CSS文件正确加载,但是当我转到另一个页面(即localhost:3000/videos )时,不显示shared/header并且CSS被破坏。
当我使用具有相同布局的Rails 3并使用CSS共享文件时,它显示正确,我缺少什么? 我没有看到Rails 4中的渲染和产量有任何变化。
视图/布局/ application.html.haml
!!! 5 %html(lang="en-US") %head %title MyFLiX4.0 %meta(charset="UTF-8") %meta(name="viewport" content="width=device-width, initial-scale=1.0") = csrf_meta_tag = stylesheet_link_tag "application" = javascript_include_tag "application" = yield :head %body %header = render 'shared/header' # This part does not display in yield %section.content.clearfix = render 'shared/messages' # This part does not display in yield = yield # This part does not load CSS properly %footer © 2013 MyFLiX4.0我有部分内容如下: 视图/共享/ _header.html.haml 视图/共享/ _messages.html.haml
github: https : //github.com/yhagio/myflix4.0/tree/master/app/views
When I load root the header displays and CSS files are loaded properly, but when I go to another page (i.e. localhost:3000/videos), the shared/header is not displayed and CSS is broken.
When I used Rails 3 with the same layout and shared files with CSS, it displayed properly, what am I missing ? I do not see any changes for rendering and yield in Rails 4.
views/layouts/application.html.haml
!!! 5 %html(lang="en-US") %head %title MyFLiX4.0 %meta(charset="UTF-8") %meta(name="viewport" content="width=device-width, initial-scale=1.0") = csrf_meta_tag = stylesheet_link_tag "application" = javascript_include_tag "application" = yield :head %body %header = render 'shared/header' # This part does not display in yield %section.content.clearfix = render 'shared/messages' # This part does not display in yield = yield # This part does not load CSS properly %footer © 2013 MyFLiX4.0I have partials as follows: views/shared/_header.html.haml views/shared/_messages.html.haml
github: https://github.com/yhagio/myflix4.0/tree/master/app/views
最满意答案
在app / controllers / videos_controller.rb中,第一行应该是
class VideosController < ApplicationController不
class VideosController < ActionController::BaseIn app/controllers/videos_controller.rb, line one should be
class VideosController < ApplicationControllernot
class VideosController < ActionController::Base更多推荐
发布评论