Sinatra can't see styles.css -
in directory have:
- shop.rb (app < sinatra::base)
- lib directory - ruby models inside
- views directory - erb files inside
- gemfile
where should place style.css ? tried every place possible, created public folder , tried every possible place, styles doesn't work. in layout have:
<link rel="stylesheet" href="/style.css"/>
i tried with:
<link rel="stylesheet" href="style.css"/>
it might because app not configured find public directory/ first make sure public directory exists relative main entry file of application (assuming shop.rb) , use following configuration:
class shop < sinatra::base configure set :public_folder, file.expand_path('../public', __file__) set :views , file.expand_path('../views', __file__) set :root , file.dirname(__file__) end '/' erb :index end end
once set up, sinatra should know find public directory , can include asset file this:
css:
<link rel="stylesheet" href="/style.css"/>
image:
<img src="/img/background.png" alt="image" />
javascript:
<script src="/js/main.js"></script>
Comments
Post a Comment