ruby - Sinatra can't serve JavaScript files without help? Is this correct? -
OK, so I do not have a problem saying this copy, but I have to make sure that I am doing it right Because it does 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 (I want to include the file) >
- Model /
- View
- Layout
- Layout .h
- route
- init.rb
- bootstrap.rb (included in init.rb)
When I try to include the file (without any extra route or anything) I can not find a page error, however, if I add this code, then this is true Works:
get '/ media / js /: name' start sending send_file ('media / js /' + params [: name]) Rescue "nothing for me "End of End"
I have no problem doing this to serve my media / stable files, but I want to make sure that it is necessary, I would like to This is possible to avoid.
edit
I had included the following code in my bootstrap.rb file, but it has no effect:
< Code> set: root, file. Dynamic (__ file__) enabled: static
- init.js (I want to include the file) >
- js /
From:
You can specify a different location:Static Files. / Public directory. Public option:
set: public, File.dirname (__ FILE__) + '/ static'
You are serving with the Media
directory.
Comments
Post a Comment