简体   繁体   English

Rails CSS没有使用Heroku加载

[英]Rails CSS not Loading using Heroku

UPDATE : The full site code is here - https://github.com/eWizardII/PeerInstruction 更新 :完整的网站代码在这里 - https://github.com/eWizardII/PeerInstruction

I have the following site set up here on Heroku - http://www.peerinstruction.net/users/sign_up the issue is that I have updated the css yet it is not being actively reflected on the site, it just shows a textbox, with some edited/custom fonts. 我在Heroku上设置了以下站点 - http://www.peerinstruction.net/users/sign_up问题是我已经更新了css但它没有在网站上积极反映,它只显示了一个文本框,使用一些编辑/自定义字体。 I have attached the css file in the following gist - https://gist.github.com/f74b626c54ecbb60bbde 我已将css文件附加在以下要点中 - https://gist.github.com/f74b626c54ecbb60bbde

The signup page controller: 注册页面控制器:

!!! Strict
%html
  %head
    %title= yield(:title) || "Untitled"
    = stylesheet_link_tag 'application', 'web-app-theme/base', 'web-app-theme/themes/activo/style', 'web-app-theme/override'
    = javascript_include_tag :defaults
    = csrf_meta_tag
    = yield(:head)
  %body
    #container
      #header
        %h1
          %a{:href => "/"} Peer Instruction Network
        #user-navigation
          %ul.wat-cf
            %li
              .content.login
                .flash
                  - flash.each do |type, message|
                    %div{ :class => "message #{type}" }
                      %p= message
                = form_for(resource, :as => resource_name, :url => session_path(resource_name), :html => { :class => "form login" }) do |f|
                  .group.wat-cf
                    .left= f.label :email, :class => "label right"
                    .right= f.text_field :email, :class => "text_field"
                  .group.wat-cf
                    .left= f.label :password, :class => "label right"
                    .right= f.password_field :password, :class => "text_field"
                  .group.wat-cf
                    .right
                      %button.button{ :type => "submit" }
                        Login
              /= link_to "Sign In", destroy_user_session_path
      #box
        = yield

The signup pages haml file: 注册页面haml文件:

%h2
.block
  .content.login
    .flash
      - flash.each do |type, message|
        %div{ :class => "message #{type}" }
          %p= message
      = form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f|
        = devise_error_messages!
        %div
          = f.label :firstname
          %br/
          = f.text_field :firstname
        %div
          = f.label :middlename
          %br/
          = f.text_field :middlename
        %div
          = f.label :lastname
          %br/
          = f.text_field :lastname
        %div
          = f.label :email
          %br/
          = f.email_field :email
        %div
          = f.label :password
          %br/
          = f.password_field :password
        %div
          = f.label :academic
          %br/
          = f.text_field :academic
        %div= f.submit "Continue"
      = render :partial => "devise/shared/links"

I used web-app-theme to create an activo theme and then modify it. 我使用web-app-theme创建一个activo主题,然后进行修改。

here is your working app 这是你的工作应用程序

I had to do a few things to fix it. 我必须做一些事来解决它。

Firstly, I put it on cedar stack, that's important. 首先,我把它放在雪松堆上,这很重要。

Then, it's vital to change your Gemfile. 然后,更改Gemfile至关重要。 I made a Gist of what I did there but in short I moved sqlite3 into dev and test envs, and I removed the rubyracer gem. 我做了一个要点我所做的有,但总之我感动到sqlite3的开发和测试ENVS,和我删除了rubyracer宝石。

I think that's all I did. 我认为这就是我所做的一切。

I'd get into the habit of removing compiled assets that are no longer being used by the way, as they will just take up loads of space in public/assets 我养成了删除不再被使用的编译资产的习惯,因为它们只会占用public/assets大量空间

I validated your css and it comes up with lots of warnings about invalid properties. 验证了你的css ,它提出了很多关于无效属性的警告。

I suspect it is some sort of character set mismatch between what is being served and what is in the document. 我怀疑它正在服务的内容与文档中的内容之间存在某种字符集不匹配。 Because of the CSS not parsing, none of the CSS will work. 由于CSS没有解析,所以CSS都不起作用。

Few problems, overide.css is not is not found. 几乎没有问题,overide.css不是没有找到。 You have a 404: 你有404:

http://www.peerinstruction.net/assets/web-app-theme/override.css http://www.peerinstruction.net/assets/web-app-theme/override.css

Make sure to include web-app-theme/override.css on your assets/stylesheets/application.css and run: 确保在您的assets / stylesheets / application.css中包含web-app-theme / override.css并运行:

RAILS_ENV=production rake assets:precompile

before you push to heroku 在你推到heroku之前

I just got bit by "css assets not loading on Heroku". 我刚刚得到“css资产没有加载在Heroku上”。

My problem was that I forgot to compile the assets locally -- which is something you must do if a public/assets/manifest.yml is detected in your app. 我的问题是我忘了在本地编译资产 - 如果在你的应用中检测到public/assets/manifest.yml你必须这样做。 The presence of this file tells Heroku that you are handling asset compilation yourself and will not attempt to compile your assets. 此文件的存在告诉Heroku您自己正在处理资产编译,并且不会尝试编译您的资产。

See Rails 3.1 on Heroku Cedar 请参阅Heroku Cedar上的Rails 3.1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM