Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rails 4.1 add videos folder to asset pipeline

Here are my paths so far:

assets
>fonts
>images
>stylesheets
>javascripts
>videos

I would like to bucket videos under the videos folder, but I can not seem to get them to be show up. My current assets.rb initializer looks like:

Rails.application.config.assets.precompile += %w( layout-home.css layout-error.css layout-static-page.css layout-brand.css )
Rails.application.config.assets.precompile += %w( layout-home.js layout-static-page.js layout-brand.js )
Rails.application.config.assets.precompile += [ Dir.glob("#{Rails.root}/app/assets/videos/**/") ]

Any ideas on how to adjust this? No matter how I adjust that last line, I can not get them to pull in.

like image 425
Chris Hough Avatar asked Aug 03 '14 00:08

Chris Hough


People also ask

How do you Precompile an asset?

To compile your assets locally, run the assets:precompile task locally on your app. Make sure to use the production environment so that the production version of your assets are generated. A public/assets directory will be created. Inside this directory you'll find a manifest.

What does rake assets Clean do?

rake assets:clean Only removes old assets (keeps the most recent 3 copies) from public/assets . Useful when doing rolling deploys that may still be serving old assets while the new ones are being compiled.

What are rails sprockets?

Sprockets is a crucial Ruby library that is used to serve and compile web assets. However, in Rails 7.0 the library becomes an optional dependency unless the application needs to use Sprockets. In such situations, the sprockets-rails gem will have to be added to the Gemfile .


1 Answers

Add the following to config/initializers/assets.rb

Rails.application.config.assets.paths << "#{Rails.root}/app/assets/videos"

Do not forget to restart the server after changing an initializer.

like image 178
Chris Hough Avatar answered Sep 26 '22 12:09

Chris Hough