Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>OK, so here's the solution:</p> <p>Internally, the asset pipeline (aka Sprockets) require directive calls <code>context.require_asset()</code> to actually require whatever path is specified in the directive. Turns out, that means that the <code>require_asset</code> method is present and available during ERB expansion. So, the correct solution was:</p> <pre><code>// ... Standard application.js stuff here ... //= require_tree . &lt;% Rails.plugins.each do |plugin| require_asset(plugin.to_s) end %&gt; </code></pre> <p>Added that in, and all worked as expected. Whew!</p> <p>In case you're wondering about that <code>Rails.plugins</code> bit, I added an extension to the Rails module to get the actual list of plugins that are loaded, in load order, based on config.plugins. For completeness, here it is:</p> <pre><code>module Rails def self.plugins # Get sorted list of all installed plugins all = Dir.glob(Rails.path('vendor/plugins/*/init.rb')).collect {|p| p.extract(/\/([^\/]+)\/init.rb$/) } all.sort! all.collect! {|p| p.to_sym } # Get our load order specification load_order = Rails.application.config.plugins # Split the load order out, and re-assemble replacing the :all keyword with the # set of plugins not in head or tail head, tail = load_order.split(:all) all -= head all -= tail # All set! head + all + tail end end </code></pre> <p>And the final detail was creating a <code>&lt;plugin_name&gt;.js</code> manifest file in each plugin's app/assets/javascripts directory.</p> <p>Hope that helps someone!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload