ruby on rails - How to correctly write a path to stylesheets in application layout? -


i want include bootstrap.min.css file project , located in (project)/css/bootstrap.min.css folder. added following line in application layout between <head> tags.

<head>   <title>greenbull</title>   <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>   <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>   <%= csrf_meta_tags %>   <link rel="stylesheet" href="path/css/bootstrap.min.css"> </head> 

however when run app, console renders error enter image description here

enter image description here

why so?

enter image description here

as mentioned preferred way of including assets rails application use asset pipeline. in event need include asset lives outside of default include paths setup rails (in case css/bootstrap.min.css) can add custom path application.

by adding following config/initializers/assets.rb:

config.assets.paths << rails.root.join("css") 

rails assets in /css when using javascript_include_tag or stylesheet_link_tag within layout/application.html.erb. need tell rails name of asset precompile since using filename other application.js or application.css. add following config/initializers/assets.rb file:

rails.application.config.assets.precompile += %w( bootstrap.min.css ) 

in layout/application.html.erb able tell rails load stylesheet.

<%= stylesheet_link_tag 'bootstrap.min', media: 'all' %> 

Comments

Popular posts from this blog

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -