Required Asset Files from Subdirectories of the Asset Path

I am trying to upgrade my application to Rails 3.1, and I have quite a few custom Javascript files that I am trying to transfer to the pipeline of new assets.

In my current (i.e. pre-3.1) directory structure, there is something like:

public/
    foo/
        model.js
        controller.js
        etc...

So, I'm trying to move them to lib / assets / javascripts and keep the foo / subdirectory intact (instead of make foo_model.js, foo_controller.js, etc.).

In my application.js application, I tried to do:

//= require foo/model

and

//= require 'foo/model'

But that will not work. Rails always gives me an error page and says:

couldn't find file 'foo/model.js'

, , , , , lib/assets - . , , , , foo_model.js ..

+5
2

,

, Rails.application.config.assets.paths rails

application.rb,

config.assets.paths += ["/path/to/lib/assets/javascript/foo"]
+6

, , , , ( ) config/application.rb. : http://guides.rubyonrails.org/asset_pipeline.html#asset-organization

:

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

+1

All Articles