Reputation: 4391
My assets are working perfectly in development on my local machine. However, when I deploy to Heroku the styles are not working.I have the following directory structure. What do I need to do in order to get my assets working on 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 directories, 24 files
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
require './main'
run Sinatra::Application
Upvotes: 1
Views: 794
Reputation: 12251
You can't write to the filesystem with Heroku. Either precompile the assets (via sinatra-assetpack or otherwise) and check them in and then push, or use your own sass route.
Upvotes: 1