Search code examples
ruby-on-railsrubywebpacker

Ruby on Rails webpacker asset_pack_path throws undefined method asset_path


I'm working on a Ruby on Rails app that is using Webpacker. I get a strange undefined method error when using asset_pack_path - a NoMethodError is thrown and says undefined method 'asset_path' Did you mean? asset_pack_path. This is a similarly named method but not the one I am calling; asset_path does not appear in the app's codebase either.

I believe to be calling the correct path inside of asset_pack_path but that does not seem to be consistent with the error. Perhaps there is a versioning mis-match somewhere? I am at a loss with this one. Any ideas or suggestions to resolve this undefined method error and use asset_pack_path would be helpful. Thanks!

enter image description here


Solution

  • It turned out that asset_path was called inside the asset_pack_path method - both ActionView::Helpers::AssetUrlHelper Webpacker::Helper need to be included for asset_pack_path to work