0

dealing with an interesting problem. I'm using a third party plug in, Galleria. It runs from the body of the view like so

<script>
Galleria.loadTheme('/assets/galleria/themes/classic/galleria.classic.min.js');
Galleria.run('.galleria'...
</script>

I've realized that with the Rails asset pipeline, I have to use helper tags, otherwise the asset doesn't load. Therefore I subbed the first line out like so:

Galleria.loadTheme("<%= javascript_include_tag 'galleria.classic.min.js', '/galleria/themes/classic' %>");

But I'm not sure what to do about the Galleria.run('.galleria' part, since that's not an asset, that's telling it to run the thing that it should have loaded. Leaving it as is has not worked, so wanted to see if there were any other ideas.

EDIT: What ended up working was this lovely post from someone else, + a few bits that I had to add on myself: How to use Galleria plugin with Rails 4 Pipeline

Community
  • 1
  • 1
james
  • 3,989
  • 8
  • 47
  • 102
  • See answer here: http://stackoverflow.com/questions/21180215/how-to-use-galleria-plugin-with-rails-4-pipeline/21818262#21818262 – james Feb 16 '14 at 23:33
  • Answer here: http://stackoverflow.com/questions/21180215/how-to-use-galleria-plugin-with-rails-4-pipeline/21818262#21818262 – james Feb 16 '14 at 23:35

2 Answers2

0

I think you want

Galleria.loadTheme("<%= javascript_include_tag '/galleria/themes/classicgalleria.classic.min.js'%>")

Assuming you've put the js in assets/javascripts?

j-dexx
  • 10,286
  • 3
  • 23
  • 36
  • yes, but the way javascript_include_tag works per this site: http://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-image_alt is that you have to separate the actual file from the directory. it's weird – james Feb 16 '14 at 18:36
0

You may need to add something to the assets path for compilation. I think you can't do the javascript_include_tag directly in line. That should generate a full <script></script> tag. What you really want is just the asset compiled filename. If you've put the javascript files in vendor/assets/javascripts then add them to the precompile list

# in environments/production.rb
config.assets.precompile += %w( galleria.classic.min.js )

then I think you can include it like this:

Galleria.loadTheme('/assets/galleria.classic.min.js');

You may need to use a different path helper to get the digest version if the non-digest version is not available. I should look something like:

Galleria.loadTheme('<%= asset_path 'galleria.classic.min.js' %>');

Good luck. Galleria is a nice slideshow.

mr rogers
  • 3,200
  • 1
  • 19
  • 31