Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 3 未在Heroku/Thin上提供静态资产_Ruby On Rails 3_Heroku_Thin - Fatal编程技术网

Ruby on rails 3 未在Heroku/Thin上提供静态资产

Ruby on rails 3 未在Heroku/Thin上提供静态资产,ruby-on-rails-3,heroku,thin,Ruby On Rails 3,Heroku,Thin,我在Heroku上没有提供静态资产(图像、js和样式表)方面遇到了问题。 在我的本地开发环境中运行良好 错误如下所示: 2011-08-08T02:58:45+00:00 app[web.1]: Started GET "/stylesheets/reset.css" for 98.234.235.21 at 2011-08-07 19:58:45 -0700 2011-08-08T02:58:45+00:00 app[web.1]: 2011-08-08T02:58:45+00:00 app

我在Heroku上没有提供静态资产(图像、js和样式表)方面遇到了问题。 在我的本地开发环境中运行良好

错误如下所示:

2011-08-08T02:58:45+00:00 app[web.1]: Started GET "/stylesheets/reset.css" for 98.234.235.21 at 2011-08-07 19:58:45 -0700
2011-08-08T02:58:45+00:00 app[web.1]: 
2011-08-08T02:58:45+00:00 app[web.1]: ActionController::RoutingError (No route matches "/stylesheets/reset.css"):
我正在使用:

  • Ruby 1.9.2
  • Rails 3.0.7
  • Heroku与Bambon-mri-1.9.2和瘦Web服务器。(我遵循heroku.com上的默认基本设置说明)
我在google/stackoverflow上搜索过,并尝试了以下方法,但没有成功:

  • 删除config.ru
  • 使用ActionDispatch::Static“#{Rails.root}/public”
    添加到config.ru
  • 在staging.rb中设置
    config.service\u static\u assets=true
有人能提出解决办法吗?我应该用雪松而不是竹子吗?我应该用别的东西而不是薄的吗

谢谢


编辑: 提供js文件,但图像和样式表不提供。 我检查了链接中的路径是否一致

myapp.heroku.com/stylesheets/reset.css
-失败
myapp.heroku.com/javascripts/jquery.js
-成功

我还尝试设置以下内容:
config.action\u dispatch.x\u sendfile\u header=nil
。 这与
config.service\u static\u assets=true一起使用,但注意到Heroku强制执行这些选项,无论您如何设置它们。i、 e.在启动过程中执行以下操作:

-----> Detected Rails is not set to serve static_assets
       Installing rails3_serve_static_assets... done
-----> Configure Rails 3 to disable x-sendfile   
       Installing rails3_disable_x_sendfile... done

我不确定Heroku是否在
暂存
环境中运行,我认为它是在
生产
环境中运行的,这就是为什么没有应用您的设置。

问题是资产文件没有推送到Heroku(我是git出错,不是Heroku问题)

Heroku的支持人员在我联系他们时指出了这一点。他们迅速作出了详细答复,其中还包括以下评论:

  • Heroku gem不需要在Heroku上运行
  • 在Gemfile中指定postgres gem;在本地使用postgres代替sqlite3进行开发
  • config.ru:不要直接运行调度程序,请运行应用程序容器
  • 不要将x_sendfile_头设置为nil,因为这在Rails 3上不受正确支持(这是Rails 3.1设置)

Ryan,我将其配置为运行暂存,并验证是否应用了我的更改:
heroku config--remote staging
显示了
RACK_ENV=>staging
RAILS_ENV=>staging