23

Is it possible to move SWF files to the asset pipeline, and if possible how can this be done?

Rubytastic
  • 15,001
  • 18
  • 87
  • 175

1 Answers1

42

I would recommend putting them in a folder called app/assets/flash.

Add this folder to your asset paths:

config.assets.paths << Rails.root.join('app', 'assets', 'flash')

They can be referenced like this in your views:

asset_path('name_of_swf')

The asset_path helper will ensure the correct file is referenced in development and production modes.

Brad Werth
  • 17,411
  • 10
  • 63
  • 88
Richard Hulse
  • 10,383
  • 2
  • 33
  • 37
  • Great great Did not knew you could extend assets paths like that, thx ! For reference you add this config.assets.path << etc in /config/application.rb – Rubytastic Jan 24 '12 at 18:28
  • 2
    But isn't app/assets only for files that need to be precompiled? A swf is a binary and requires no precompilation. – Undistraction Jul 07 '12 at 17:00
  • 5
    Any binary files that are put in the pipeline get a fingerprint added to them so that you can take advantage of far-future headers and client-side caching. – Richard Hulse Jul 08 '12 at 21:38
  • How would you refer to this in a script? – ErnestoE Jun 30 '15 at 07:16
  • asset_path('name_of_file') assuming the file is somewhere in the assets folder. If it is in a folder than you need to include that. – Richard Hulse Jul 02 '15 at 07:01