webpacker: Getting undefined method `javascript_pack_tag' for ...
Having Rails 5 application and followed this tutorial https://medium.com/statuscode/introducing-webpacker-7136d66cddfb#.4xpiogt9l how to install and run webpacker.
Having webpacker in Gemfile
gem 'webpacker', github: 'rails/webpacker'
And used installation commands
rails webpacker:install
rails webpacker:install:react
And when open page with <%= javascript_pack_tag 'app' %>
I am getting undefined method 'javascript_pack_tag' for #<#<Class:0x007f8d5a158378>:0x007f8d5a0015b0>
./bin/webpack-dev-server runs fine (but having some babel errors, but I guess that can’t have impact on previous error).
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 12
- Comments: 33 (11 by maintainers)
Commits related to this issue
- Merge pull request #288 from gauravtiwari/fix-view-helpers Include webpacker helper to action view #172 — committed to rails/webpacker by guilleiguaran 7 years ago
- Развернул первый проект на рельсах Поставил сервер, исправил косяк с запуском (решение нашел здесь - https://github.com/rails/webpacker/issues/172#issuecomment-520119164). Релаизовано: CRU (из CRUD) ... — committed to pacstudios/Blog by pacstudios 4 years ago
Don’t forget to restart your server :trollface:
Please could you all try latest master -
bundle update webpacker
. This issue is now fixed 🎉 🍰I had to stop the server, then run
bin/spring stop
thenrails s
Then, thejavascript_pack_tag
worked. (Restarting the server wasn’t sufficient.)But what has me curious is that I didn’t need to start
bin/webpack-dev-server
(I thought that was my problem originally) I am curious when, and where, that is needed.I ran into a similar issue when adding webpacker
erb
support.For me (and hopefully anyone reading this), the issue was caused by the js-style comment (as suggested earlier by another comment):
The solution is to make sure there is no
<% ...
tags anywhere in the code, including JS comments.I’ve also run into this issue on rails 5.1.0.rc2 the project is using active admin but it doesn’t use any
before_action
configuration. I’ve not had a change to look into what is causing this as yet and the work around fixes the issue for now. If I get a chance to look into this more deeply I’ll report back here.@schovi Could you please add
require 'webpacker/railtie'
in the list and then retry running without including helper in the controller? The one I have gotrequire 'rails/all'
, which means it adds everything.If yes to above, do you got javascript comments in that file? Please remove that since it’s erb. I have made a demo for you here - https://tranquil-inlet-61365.herokuapp.com/ and code is here - https://github.com/gauravtiwari/webpacker-demo-app