Skip to content

Conversation

@s6577t
Copy link
Contributor

@s6577t s6577t commented Jul 8, 2014

When running bundle console we get this error:

>>: bundle console
Resolving dependencies...
./lib/react/rails/view_helper.rb:27:in `<top (required)>': uninitialized constant ActionView (NameError)
...

I could have also checked with defined? ActionView::Base before including, but this would mean that if ActionView::Base was defined elsewhere later, the react rails helpers would not be included.

React Rails View Helpers are included in a way which works
regardless of whether ActionView::Base is already defined.
This prevents an error while also continuing to work as
expected if ActionView::Base is later defined by Rails.
@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@sophiebits
Copy link
Member

Perhaps we shouldn't be loading view_helper.rb at all in bundle console?

@charypar
Copy link

Any update on this? Is there anything we can do? We'd like to switch back to the mainline repo (currently using @sjltaylor's fork).

@s6577t
Copy link
Contributor Author

s6577t commented Jul 24, 2014

@spicyj Do you mean something like this: #67 ?
The disadvantage is it wouldn't be included in ActionView::Base if ActionView::Base was loaded later

@xionon
Copy link
Contributor

xionon commented Jul 24, 2014

@sjltaylor @spicyj I think the "rails way" of handling this would be to use a new initializer block in the Railtie.

# would add to lib/react/rails/railtie.rb
initializer "react_rails.setup_view_helpers" do
  ActionView::Base.send :include, ::React::Rails::ViewHelper
end

@s6577t
Copy link
Contributor Author

s6577t commented Jul 24, 2014

@xionon, great suggestion, thanks. Like this then: #68

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants