#[1]gnikyt feed [2]gnikyt Code ramblings. Precompiling assets in your Rails Engine /* May 03, 2016 — 2.3KB */ This will be a quick post to highlight an issue I had where I needed to precompile an asset file for my Rails engine that was not to be compiled with the other engine assets. Recently, I added [3]TinyMCE-Rails to Guts instead of rolling it in on its own. This allows me to abstract TinyMCE so it’s handled by the gem, and allows users to provide their own customizations and configurations. Previously, I had a custom plugin that was hard-coded into TinyMCE as a simple button to allow users to add media from Guts into the editor. Now, using the gem, I need to make this a plugin, but I found issues getting the plugin file into production… it would never appear in shared/public when deploying the website via Capistrano after precompile ran. I was frustrated at first but knew it had to be a simple answer, I just needed to tell Rails about the file. This was the directory structure: app/ assets/ javascripts/ guts/ ... tinymce/ plugins/ guts_media/ plugin.js I needed my tinymce/plugins/ folder to move into public/assets/tinymce generated by the TinyMCE gem. After trial and error, the answer was simple and stupid… why didn’t I think of it before? I simply need to open my engine’s file and append my plugin path to assets.precompile provided by Rails. Here was the final working result (bottom of the file): # Guts' module namespace module Guts # Guts' engine class class Engine < ::Rails::Engine # Isolate Guts routes isolate_namespace Guts # Autoload concerns config.autoload_paths << "#{config.root}/app/concerns" # Allow decorator usage for extending Guts config.to_prepare do Dir.glob("#{Rails.root}/app/decorators/*/guts/*_decorator*.rb").each do |c | require_dependency(c) end end # Load in our custom assets to precompile config.assets.precompile << "#{config.root}/app/assets/javascripts/tinymce/p lugins/guts_media/plugin.js" end end I hope this helps anyone else stuck in a similar situation. [4]MD | [5]TXT | [6]CC-4.0 This post is 8 years old and may contain outdated information. __________________________________________________________________ [7]Ty King Ty King A self-taught, seasoned, and versatile developer from Newfoundland. Crafting innovative solutions with care and expertise. See more [8]about me. [9]Github [10]LinkedIn [11]CV [12]RSS * * * * * * * * * * References Visible links: 1. /rss.xml 2. / 3. https://github.com/spohlenz/tinymce-rails 4. /precompiling-assets-in-your-rails-engine/index.md 5. /precompiling-assets-in-your-rails-engine/index.txt 6. https://creativecommons.org/licenses/by/4.0/ 7. /about 8. /about 9. https://github.com/gnikyt 10. https://linkedin.com/in/gnikyt 11. /assets/files/cv.pdf 12. /rss.xml Hidden links: 14. localhost/tmp/lynxXXXXv52bw2/L768266-1835TMP.html#cb2-1 15. localhost/tmp/lynxXXXXv52bw2/L768266-1835TMP.html#cb2-2 16. localhost/tmp/lynxXXXXv52bw2/L768266-1835TMP.html#cb2-3 17. localhost/tmp/lynxXXXXv52bw2/L768266-1835TMP.html#cb2-4 18. localhost/tmp/lynxXXXXv52bw2/L768266-1835TMP.html#cb2-5 19. localhost/tmp/lynxXXXXv52bw2/L768266-1835TMP.html#cb2-6 20. localhost/tmp/lynxXXXXv52bw2/L768266-1835TMP.html#cb2-7 21. localhost/tmp/lynxXXXXv52bw2/L768266-1835TMP.html#cb2-8 22. localhost/tmp/lynxXXXXv52bw2/L768266-1835TMP.html#cb2-9 23. localhost/tmp/lynxXXXXv52bw2/L768266-1835TMP.html#cb2-10 24. localhost/tmp/lynxXXXXv52bw2/L768266-1835TMP.html#cb2-11 25. localhost/tmp/lynxXXXXv52bw2/L768266-1835TMP.html#cb2-12 26. localhost/tmp/lynxXXXXv52bw2/L768266-1835TMP.html#cb2-13 27. localhost/tmp/lynxXXXXv52bw2/L768266-1835TMP.html#cb2-14 28. localhost/tmp/lynxXXXXv52bw2/L768266-1835TMP.html#cb2-15 29. localhost/tmp/lynxXXXXv52bw2/L768266-1835TMP.html#cb2-16 30. localhost/tmp/lynxXXXXv52bw2/L768266-1835TMP.html#cb2-17 31. localhost/tmp/lynxXXXXv52bw2/L768266-1835TMP.html#cb2-18 32. localhost/tmp/lynxXXXXv52bw2/L768266-1835TMP.html#cb2-19 33. localhost/tmp/lynxXXXXv52bw2/L768266-1835TMP.html#cb2-20 34. localhost/tmp/lynxXXXXv52bw2/L768266-1835TMP.html#cb2-21