Rails 4,不会在共享文件夹中渲染部分内容,也不会正确加载CSS以获得收益(Rails 4, does not render partials in shared folder and not l

编程入门 行业动态 更新时间:2024-10-25 15:33:20
Rails 4,不会在共享文件夹中渲染部分内容,也不会正确加载CSS以获得收益(Rails 4, does not render partials in shared folder and not loading CSS properly for yield)

当我加载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 &copy 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 &copy 2013 MyFLiX4.0

I 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::Base

In app/controllers/videos_controller.rb, line one should be

class VideosController < ApplicationController

not

class VideosController < ActionController::Base

更多推荐

本文发布于:2023-08-07 18:52:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1466017.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:会在   部分内容   收益   共享文件夹   加载

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!