【问题标题】:Rails 4, does not render partials in shared folder and not loading CSS properly for yieldRails 4,不在共享文件夹中渲染部分,也没有正确加载 CSS 以提高产量
【发布时间】:2013-10-26 13:32:05
【问题描述】:

当我加载根目录时,标题显示并且 CSS 文件正确加载,但是当我转到另一个页面(即localhost:3000/videos)时,shared/header 不显示并且 CSS 损坏。

当我使用具有相同布局的 Rails 3 并使用 CSS 共享文件时,它可以正常显示,我缺少什么?我没有看到 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

我有如下部分:
views/shared/_header.html.haml
views/shared/_messages.html.haml

github:https://github.com/yhagio/myflix4.0/tree/master/app/views

【问题讨论】:

    标签: ruby-on-rails-4 haml render yield


    【解决方案1】:

    在 app/controllers/videos_controller.rb 中,第一行应该是

    class VideosController < ApplicationController
    

    不是

    class VideosController < ActionController::Base
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-09-17
      • 1970-01-01
      • 2017-05-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多