加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails-3 – 在Heroku上使用Compass:/ tmp远程和本地使

发布时间:2020-12-17 03:34:36 所属栏目:百科 来源:网络整理
导读:我目前正在使用Heroku知识库推荐的这个 configuration使用Compass和Heroku. Heroku有一个只读文件系统,因此编译好的样式表需要存储在/ tmp中.这在Heroku上工作得很好;但是,在本地,Rails希望在/ public / stylesheets中找到样式表(当通过= stylesheet_link_ta
我目前正在使用Heroku知识库推荐的这个 configuration使用Compass和Heroku. Heroku有一个只读文件系统,因此编译好的样式表需要存储在/ tmp中.这在Heroku上工作得很好;但是,在本地,Rails希望在/ public / stylesheets中找到样式表(当通过= stylesheet_link_tag’screen.css’,:media =>’screen,projection’调用时).

为了解决这个问题,我使用ln -s tmp / stylesheets / screen.css public / stylesheets / screen.css在/ public / stylesheets中创建了符号链接,这似乎有效.

有没有办法解决这个问题而不使用符号链接,也许是通过改变Rails中的一些配置?我没有取得太大的成功.

这是我的config / initializers / compass.rb:

require 'compass'
require 'compass/app_integration/rails'
Compass::AppIntegration::Rails.initialize!

# Required for Heroku:
require 'fileutils'
FileUtils.mkdir_p(Rails.root.join("tmp","stylesheets"))

Compass::AppIntegration::Rails.initialize!

Rails.configuration.middleware.delete('Sass::Plugin::Rack')
Rails.configuration.middleware.insert_before('Rack::Sendfile','Sass::Plugin::Rack')

Rails.configuration.middleware.insert_before('Rack::Sendfile','Rack::Static',:urls => ['/stylesheets'],:root => "#{Rails.root}/tmp")

这是我的config / compass.rb:

project_type = :rails
project_path = Compass::AppIntegration::Rails.root

# Set this to the root of your project when deployed:
http_path = "/"

# Necessary for Heroku (original commented out:
css_dir   = 'tmp/stylesheets'
#css_dir = "public/stylesheets/compiled"

sass_dir  = 'app/views/stylesheets'

environment = Compass::AppIntegration::Rails.env

任何帮助将不胜感激.

解决方法

我实际上正准备使用我们的Rails应用程序设置Compass,这个应用程序是在Heroku上托管的,所以欢呼为我提供借口来解决这个问题.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读