react_on_rails: Undefined method react_component
Just finished installing this as per the readme and I’m getting this:
NoMethodError - undefined method `react_component' for #<#<Class:0x007fc6e9ac2300>:0x007fc6e9ac1130>:
17:25:26 web.1 | app/views/hello_world/index.html.erb:2:in `_app_views_hello_world_index_html_erb__2737803353613407809_70246181992240'
17:25:26 web.1 | actionview (4.1.13) lib/action_view/template.rb:145:in `block in render'
17:25:26 web.1 | activesupport (4.1.13) lib/active_support/notifications.rb:161:in `instrument'
17:25:26 web.1 | actionview (4.1.13) lib/action_view/template.rb:339:in `instrument'
17:25:26 web.1 | actionview (4.1.13) lib/action_view/template.rb:143:in `render'
17:25:26 web.1 | actionview (4.1.13) lib/action_view/renderer/template_renderer.rb:55:in `block (2 levels) in render_template'
17:25:26 web.1 | actionview (4.1.13) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
17:25:26 web.1 | activesupport (4.1.13) lib/active_support/notifications.rb:159:in `block in instrument'
17:25:26 web.1 | activesupport (4.1.13) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
17:25:26 web.1 | activesupport (4.1.13) lib/active_support/notifications.rb:159:in `instrument'
17:25:26 web.1 | actionview (4.1.13) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
17:25:26 web.1 | actionview (4.1.13) lib/action_view/renderer/template_renderer.rb:54:in `block in render_template'
17:25:26 web.1 | actionview (4.1.13) lib/action_view/renderer/template_renderer.rb:62:in `render_with_layout'
17:25:26 web.1 | actionview (4.1.13) lib/action_view/renderer/template_renderer.rb:53:in `render_template'
17:25:26 web.1 | actionview (4.1.13) lib/action_view/renderer/template_renderer.rb:17:in `render'
17:25:26 web.1 | actionview (4.1.13) lib/action_view/renderer/renderer.rb:42:in `render_template'
17:25:26 web.1 | actionview (4.1.13) lib/action_view/renderer/renderer.rb:23:in `render'
17:25:26 web.1 | actionview (4.1.13) lib/action_view/rendering.rb:99:in `_render_template'
17:25:26 web.1 | actionpack (4.1.13) lib/action_controller/metal/streaming.rb:217:in `_render_template'
17:25:26 web.1 | actionview (4.1.13) lib/action_view/rendering.rb:82:in `render_to_body'
17:25:26 web.1 | actionpack (4.1.13) lib/action_controller/metal/rendering.rb:32:in `render_to_body'
17:25:26 web.1 | actionpack (4.1.13) lib/action_controller/metal/renderers.rb:32:in `render_to_body'
17:25:26 web.1 | actionpack (4.1.13) lib/abstract_controller/rendering.rb:25:in `render'
17:25:26 web.1 | actionpack (4.1.13) lib/action_controller/metal/rendering.rb:16:in `render'
17:25:26 web.1 | actionpack (4.1.13) lib/action_controller/metal/instrumentation.rb:44:in `block (2 levels) in render'
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 50 (27 by maintainers)
As all other developers here, I found this problem in my Rails 5 and React on Rails 8.0 setup. I thought it cause by my docker build setting but no. I fixed it by adding
ActiveSupport.on_load(:action_view) do include ReactOnRailsHelper endat the end ofinitializers/react_on_rails.rbor includingReactOnRailsHelperinapplication_helper.rbI prefer to including
ReactOnRailsHelperinapplication_helper.rbinstead of messing up the generated react on rails config file.I had the same issue an existing app. I added an
include ReactOnRailsHelperto application_helper and that worked.I had this same issue installing 8.0.0 to my existing app on rails 4.2, I added the following snippet to the bottom of the react_on_rails.rb initializer, restarted the server and it worked.
ActiveSupport.on_load(:action_view) do include ReactOnRailsHelper endI had same error with Rails 4.2.5.2 and this line in initializer helped me
ActiveSupport.on_load(:action_view) do include ReactOnRailsHelper endPreviously was installed react-rails:
I’ve seen this problem on Rails 4.0. Restarting
foremandidn’t change it.I think I’d just add the
on_loadcode to the initializer if I was you. I did that locally, and it fixed it.As far as I can tell:
ruby ActiveSupport.on_load(:action_view) do include ReactOnRailsHelper endengine.rb:Maybe @brandonhilkert might have an opinion. He wrote an article HOW TO BUILD A RAILS ENGINE
I’m unfortunately getting the same error with matching stack trace. Tried clearing out my gems and re-installing everything but no avail.