Ok, so I'm not having trouble with this per say, but I want to make sure that I'm doing this right because it just seems like a lot of extra work in the long run.
I am working with Sinatra and using HAML templates. I want to include a JavaScript file from my HAML file. My directory structure looks like this:
- media/
- js/
- init.js (file I want to include)
- css/
- js/
- models/
- views/
- layout.haml
- routes/
- init.rb
- bootstrap.rb (included in init.rb)
When I try to include the file (with no extra routes or anything) I get a page cannot be found error. However, if I add this code, then it works fine:
get '/media/js/:name' do
begin
send_file('media/js/' + params[:name])
rescue
return "There's nothing for you here"
end
end
I have no problem doing this for serving my media/static files, but I just want to make sure that this is necessary, I would like to avoid this is possible.
EDIT
I included the following code to my bootstrap.rb file, but to no avail:
set :root, File.dirname(__FILE__)
enable :static