Requiring assets from gem doe no longer work in Rails 4.2

I have a Rails 4.1 (.10) application that I'm trying to upgrade to Rails 4.2 (.1), but I'm having a hard time getting it.

The problem has to do with how assets are loaded from a gem that I use to share assets across multiple applications.

In my gem I have the following code

# /assets_gem/app/assets/javascript/my_js.js
//= require jquery
//= require jquery_ujs
//= require jquery-ui
//= require turbolinks
//= require ../../../vendor/assets/javascripts/bootstrap/bootstrap-alert
//= require ../../../vendor/assets/javascripts/bootstrap/bootstrap-tooltip
//= require ../../../vendor/assets/javascripts/bootstrap/bootstrap-popover

      

and in assets_gem / vendor / assets / javascripts / bootstrap I have 3 js files.

In my Rails application, I have the following code

# idx/app/assets/javascripts/application.js
//= require my_js
//= require_tree ./application

      

Everything works fine in Rails 4.1.10 and Sprockets 2.12.3, but when I upgrade to Rails 4.2.1 and Sprockets 3.0.1, I get below error

Sprockets :: FileNotFound in / could not find file '../../../vendor/assets/javascripts/bootstrap/bootstrap-alert' with type 'application / javascript'

Should I claim my supplier's assets differently under Sprockets 3+?

thank

+3


source to share


2 answers


vendor/assets/javascripts

is already included in the default search path and hence all you need is, require bootstrap/bootstrap-alert

etc.



+3


source


You can also add the path to your application.rb



config.assets <Rails.root.join ('vendor', 'assets', 'my_components')

+1


source







All Articles