I have found that in my Sinatra app, when I require 'sinatra'
, I can access my public folder as expected, but when I require 'sinatra/base'
I can't. Here is my relevant code (which works until I change to /base
):
config.ru
root = ::File.dirname(__FILE__)
require ::File.join( root, 'app' )
run MyApp.new
app.rb
require 'sinatra'
require 'sinatra/namespace'
require 'haml'
class MyApp < Sinatra::Application
# ...
end
require_relative 'models/init'
require_relative 'helpers/init'
require_relative 'routes/init'
script.haml
%script(type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js")
%script(type="text/javascript" src="/js/table.js")
%link(rel="stylesheet" type="text/css" href="/css/table.css")
And yes, I have the correct directory structure in place. Like I sai开发者_高级运维d, it works using require sinatra
. Anyone know why this is occurring and what I can do to fix it?
Requiring Sinatra::Base
does not set any of the default configuration settings that requiring Sinatra
does. You'll need to set :public_folder ...
to a suitable value yourself, e.g:
set :public_folder, 'public'
精彩评论