I'm compiling some JSX assets as part of my Rails 4 app with ReactJS (using the gem) and I'm unable to use route helpers despite including them as specified in these answers.
/railsapp/app/assets/javascripts/components/GigSearchForm.js.jsx.erb:47:in `block in singleton class': undefined local variable or method `gigs_path' for #<#<Class:0x007f80bb0b1df8>:0x007f80bb1528e8> (NameError)
As you can see, the asset is being transformed from ERB to JSX to JS, and while processing the ERB the route helper gigs_path
cannot be found. I've already tried implementing solutions such as including an initializer like so:
Rails.application.assets.context_class.class_eval do
include ActionView::Helpers
include Rails.application.routes.url_helpers
end
Sprockets::Context.send :include, Rails.application.routes.url_helpers
Sprockets::Context.send :include, ActionView::Helpers
And at the top of the JSX file including the line: <% environment.context_class.instance_eval { include Rails.application.routes.url_helpers } %>
Nonetheless, I keep getting a similar error that gigs_path is undefined in some manner.