我正在使用Sinatra,我的资产(sass)不适用于heroku

时间:2014-01-27 19:12:15

标签: heroku sass sinatra

我的资产在本地计算机上的开发工作非常完美。但是,当我部署到Heroku时,样式不起作用。我有以下目录结构。为了让我的资产在Heroku上工作,我需要做什么?

.
├── Gemfile
├── Gemfile.lock
├── codekit-config.json
├── config.ru
├── development.db
├── main.rb
├── public
│   ├── assets
│   │   ├── css
│   │   │   ├── styles.css
│   │   │   └── styles.scss
│   │   ├── images
│   │   │   ├── logo.png
│   │   │   └── sinatra.jpg
│   │   ├── js
│   │   └── sass
│   └── favicon.ico
├── song.rb
└── views
    ├── about.haml
    ├── contact.haml
    ├── edit_song.haml
    ├── home.haml
    ├── layout.haml
    ├── login.haml
    ├── nav.haml
    ├── new_song.haml
    ├── not_found.haml
    ├── show_song.haml
    ├── song_form.haml
    └── songs.haml

7个目录,24个文件

main.app

require 'sinatra/flash'
require 'sinatra'
require './song'
require 'sass'
require 'haml'
require 'sinatra/assetpack'

register Sinatra::AssetPack
# I dont' think I need the line below if I use codekit
# get('assets/css/styles.css') { scss :styles}

configure :development do
  DataMapper.setup(:default, "sqlite3://#{Dir.pwd}/development.db")
end

configure :production do
  DataMapper.setup(:default, ENV['DATABASE_URL'])
end

assets do

  js :application, [
    '/js/jquery.js',
    '/js/app.js'
    # You can also do this: 'js/*.js'
  ]

  css :application, [
    '/assets/css/styles.css',
    '/assets/css/styles.scss',
   ]

  js_compression :jsmin
  css_compression :sass

end
configure do
  enable :sessions
  set :username, 'frank'
  set :password, 'sinatra'
end

helpers do
  def set_title
    @title ||= "Songs By Russell"
  end


end

before do
  set_title
end

get '/login' do
  haml :login
end

post '/login' do
  if params[:username] == settings.username && params[:password] == settings.password
    session[:admin] = true
    redirect to('/songs')
  else
    haml :login
  end
end

get '/logout' do
  session.clear
  redirect to('/login')
end

get '/set/:name' do
  session[:name] = params[:name]
end

get '/' do
  haml :home
end

get '/about' do
  @title = "All About This Website"
  haml :about
end

get '/contact' do
  haml :contact
end

post '/contact' do
  send_message
  flash[:notice] = "Thank you for your message. We'll be in touch soon."
end

not_found do
  haml :not_found
end

config.ru

require './main'
run Sinatra::Application

1 个答案:

答案 0 :(得分:1)

You can't write to the filesystem with Heroku。预先编译资产(通过sinatra-assetpack或其他方式)并检查它们然后推送,或使用您自己的sass route