I have an external css
, javascript
and Images
files in a separate project and wanted to include in my new rails
project. Here is my structure of folders:
external-assets/js/ <Files>
external-assets/js/plugin/<Files>
external-assets/css/<Files>
external-assets/css/plugins/<Files>
external-assets/images/<some Folders>/<Files>
external-assets/images/<Files>
So, I copied external-assets/js
folder to app/assets/javascript
and for css
I copied external-assets/css
to app/assets/stylesheets
.
and replace <link rel="icon" href="external-assets/css/plugins/bootstrap.min.css">
to <%= stylesheet_link_tag "/plugins/bootstrap.min.css" %>
in my html.erb
file. I followed the same thing for other css
files and js
files. When I start the server I got this error:
Asset filtered out and will not be served: add `Rails.application.config.assets.precompile += %w( style.css )` to `config/initializers/assets.rb` and restart your server
After searching on SO post
like: Asset filtered out and will not be served: add `config.assets.precompile and
Asset filtered out and will not be served. I need to mention my all js
and css
files to config.assets.precompile
.
Questions
1) Do I really need to mention all of js
, css
and images
file? I know the reason but I do have a lot of assets files.
2) What about If I put them in public
folder? Is it good approach?
3) There is stylesheet_link_tag
for css , javascript_link_tag
for js. What about Images?