0

正如标题所说,我无法让 Heroku 使用我的公共资产。

在本地,当使用shotgun它运行我的应用程序时。但是使用rackup(Heroku 使用的)css 和资产 404。

我在这里尝试了一堆答案(),但都没有奏效。

这是我的目录结构:

目录结构

我的 config.ru:

require 'bundler'
Bundler.require

require File.expand_path('../config/environment',  __FILE__)

run BikeShareApp

我的控制器:

class BikeShareApp < Sinatra::Base
  get '/' do
    erb :'home/index'
  end

  get '/stations' do
    @stations = Station.all
    erb :'stations/index'
  end
end

编辑:这就是我引用我的资产的方式

<link href="/css/bootstrap.min.css" rel="stylesheet">
<link href="/css/overwrite.css" rel="stylesheet">
4

1 回答 1

0

找到了。

遵循指南并将其放入我的 config.ru 工作:

run lambda { |env|
  [
    200,
    {
      'Content-Type'  => 'text/html',
      'Cache-Control' => 'public, max-age=86400'
    }
  ]
}
于 2017-08-20T09:17:29.047 回答