2

I've just started working on a simple Sinatra app and when uploading it to Heroku. None of the files in the public folder seem to be available but it works fine locally.

Are there any obvious reasons this might be happening?

Right now the code is really simple:

require 'rubygems'
require 'sinatra'
require 'bundler/setup'
require 'haml'
require 'rdiscount'

set :static, true
set :public_folder, "#{File.dirname(__FILE__)}/public"

get '/' do
  haml :landing
end

__END__

@@ layout
%html
  %head
    %meta{charset: "utf-8"}/
    %meta{content: "width=device-width, initial-scale=1.0", name: "viewport"}/
    %meta{content: "", name: "description"}/
    %meta{content: "", name: "author"}/
    %title TIL
    %link{href: "http://yui.yahooapis.com/pure/0.3.0/pure-min.css", rel: "stylesheet"}
    %link{rel: "stylesheet", href: "/styles.css"}
  %body
  = yield

@@landing
%section.hero
  .container
    .pure-g-r
      .pure-u-1
        .logo
          ...
.container
  %hr/
  .pure-g-r
    .pure-u-2-3
      .padding-box
        :markdown
          ...
    .pure-u-1-3
      .padding-box
        ..
  %hr/
  .pure-g-r
    .pure-u-1
      .padding-box
        :markdown
          ...
  %hr/
  .pure-g-r
    .pure-u-1
      .padding-box
        %h2 ...
    .pure-u-1-3
      .padding-box
        %img.img-rounded{src: "GD-thumbnail.png"}/
        :markdown
          ...
    .pure-u-1-3
      .padding-box
        %img.img-rounded{src: "AL-thumbnail.png"}/
        :markdown
          ...
    .pure-u-1-3
      .padding-box
        %img.img-rounded{src: "BP-thumbnail.png"}/
        :markdown
          ...
  %hr/
  %footer
    .row
      .col-lg-12
        %p

Local file structure is:

TIL (folder)
- app.rb
- Gemfile
- Procfile
- public (folder)
  - AL-thumbnail.png
  - BP-thumbnail.png
  - GD-thumbnail.png
  - logo.png
  - styles.css
4

1 回答 1

1

查看您的 Heroku 日志文件:

heroku 日志

如果你能看到类似的东西

Rack::Flash::SessionUnavailable - Rack::Flash 依赖于会话中间件。:

然后加

宝石“机架闪光会话”

给你 Gemfile。

还将'require'rack/flash/test''添加到您的主文件中。

这将强制 heroku 加载所需的中间件。

于 2014-01-05T11:56:04.890 回答