Home > OS >  undefined method `javascript_pack_tag' for #<ActionView::Base:0x0000000000a730>
undefined method `javascript_pack_tag' for #<ActionView::Base:0x0000000000a730>

Time:03-28

I am currently working with webpacker currently shakapacker. The structure of my generated app using rails new react-app --webpack=reactis app/javascript/application.js and not as shown below

enter image description here

I have tried adding the packs folder manually. when I add <%= javascript_pack_tag 'hello_react' %> in app/views/layouts/applcation.html.erb it gives me this error

NoMethodError in Pages#index

Showing /home/gatwiri/react-app/app/views/layouts/application.html.erb where line #8 raised:

undefined method `javascript_packs_tag' for #<ActionView::Base:0x0000000000ae60>
Did you mean?  javascript_path

controller generation

rails g controller pages index

/config/routes.rb

Rails.application.routes.draw do
  root 'pages#index'
end

NB: expected output hello react

What I have tried

using tag instead of tag_pack

CodePudding user response:

I downgraded my rails to rails 6.1.0 and restarted the project and everything worked okay

CodePudding user response:

I think you've misspelled javascript_pack_tag, the error shows javascript_packS_tag

  • Related