SInatra cannot find the static assets in the public folder

1,586 views
Skip to first unread message

planon

unread,
Feb 20, 2011, 12:18:58 AM2/20/11
to sinatrarb
I have an ordinary Sinatra app. I configured it using the readme file,
and started it using "rackup -p 4567." The problem is it cannot find
any of the assets in the public folder. I tried setting the static
assets folder's name differently, but that didn't work really. Here is
a few snippets of code from my app:

#config.ru
require 'rubygems'
require 'bundler'
require 'sinatra'
require 'jammit'

Bundler.require
Jammit.package!

require File.expand_path('./stick.rb')
run Stick

#stick.rb
class Stick < Sinatra::Base
get '/' do
haml :index
end
end

No idea what's going on and why it cannot find the assets in the
public folder.

Konstantin Haase

unread,
Feb 23, 2011, 1:56:54 PM2/23/11
to sina...@googlegroups.com
1. don't require 'sinatra', require 'sinatra/base' instead
2. add `enable :static`

Konstantin

> --
> You received this message because you are subscribed to the Google Groups "sinatrarb" group.
> To post to this group, send email to sina...@googlegroups.com.
> To unsubscribe from this group, send email to sinatrarb+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/sinatrarb?hl=en.
>

marco

unread,
Feb 26, 2011, 7:01:48 AM2/26/11
to sinatrarb
I am having this issues too.
Already tried "enable :static", but didn't work.
Using Bundler.

Anyone has any ideas?

marco

unread,
Feb 26, 2011, 7:12:10 AM2/26/11
to sinatrarb
All right, I figured it out.
I guess depending on how you call the app, sinatra might loose some
references on what is the root of the app, so there's :

set :root, File.dirname(__FILE__)

to correct that.

I found that here: http://www.sinatrarb.com/configuration.html

I guess it would be a good practice always set the root this way, just
in case.



On Feb 23, 3:56 pm, Konstantin Haase <k.ha...@finn.de> wrote:

Konstantin Haase

unread,
Feb 28, 2011, 3:05:41 AM2/28/11
to sina...@googlegroups.com
Add `set :app_file, __FILE__`.

Konstantin

Reply all
Reply to author
Forward
0 new messages