Skip to content

Conversation

@s6577t
Copy link
Contributor

@s6577t s6577t commented Aug 4, 2014

As discussed in #68

@s6577t
Copy link
Contributor Author

s6577t commented Aug 4, 2014

I'm currently testing this in a Rails 4 app

@s6577t
Copy link
Contributor Author

s6577t commented Aug 4, 2014

From: /vagrant/react-rails/lib/react/rails/railtie.rb @ line 25 :

    20:       end
    21:
    22:       # Include the react-rails view helper lazily
    23:       initializer "react_rails.setup_view_helpers" do
    24:         ActiveSupport.on_load(:action_view) do
 => 25:           binding.pry
    26:           include ::React::Rails::ViewHelper
    27:         end
    28:       end
    29:
    30:       # run after all initializers to allow sprockets to pick up react.js and

[1] pry(ActionView::Base)> 

@s6577t
Copy link
Contributor Author

s6577t commented Aug 4, 2014

The blocks context is ActionView::Base; this works

@xionon
Copy link
Contributor

xionon commented Aug 4, 2014

Code: 👍

CI Fail: "ReferenceError: Can't find variable: Turbolinks"

This is the most annoying bug. I am 99% sure that it's not your code that failed, it's that sometimes Poltergeist isn't waiting for the javascript to fully finish parsing before it tries to call Turbolinks.

I had to work around it using sleep(1) in xionon@decfcae

@zpao
Copy link
Member

zpao commented Aug 4, 2014

This supersedes both #61 & #68, correct?

As long as this still works in Rails < 4 (looks like jruby tests are all passing so I assume it does), then this seems fine to me. The Turbolinks thing is annoying :/

@xionon
Copy link
Contributor

xionon commented Aug 4, 2014

@zpao Correct, this supersedes both #61 and #68

I created #75 to help me remember to work on the Turbolinks thing tomorrow.

@s6577t
Copy link
Contributor Author

s6577t commented Aug 4, 2014

The lazy load feature was introduced in Rails 3 (http://simonecarletti.com/blog/2011/04/understanding-ruby-and-rails-lazy-load-hooks/)

@zpao
Copy link
Member

zpao commented Aug 4, 2014

Awesome, thanks guys!

zpao added a commit that referenced this pull request Aug 4, 2014
Lazy load the React Rails view helper in a railstie
@zpao zpao merged commit bfdb39f into reactjs:master Aug 4, 2014
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.

3 participants