Skip to content

How to point to compiled assets outside controllers/views #471

Closed Answered by tomdracz
afdev82 asked this question in Q&A
Discussion options

You must be logged in to vote

You can try include the relevant helpers in your class. Shakapacker relies on some Rails helpers so you would need them also. Something like:

class MyTestClass
  include Shakapacker::Helper
  include ActionView::Helpers
  include ActionView::Helpers::AssetTagHelper
end

MyTestClass.new.asset_pack_path('my_pack_path.js')

You can see how we do something similar (though with extend as we want the module methods to be class rather than instance methods) in one of the specs https://github.com/shakacode/shakapacker/blob/main/spec/shakapacker/helper_spec.rb

Replies: 2 comments 12 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by afdev82
Comment options

You must be logged in to vote
12 replies
@afdev82
Comment options

@afdev82
Comment options

@tomdracz
Comment options

@afdev82
Comment options

@afdev82
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants