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

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -