Skip to content

Conversation

ku1ik
Copy link

@ku1ik ku1ik commented Apr 11, 2014

Without :group => :all you can't rake assets:precompile when you
have config.initialize_on_precompile = false.

I'm not sure if there are any downsides for doing this but it seems to be working fine for us.

Without `:group => :all` you can't `rake assets:precompile` when you
have `config.initialize_on_precompile = false`.
@ku1ik
Copy link
Author

ku1ik commented Apr 11, 2014

Fixes #23 and #30.

@jtmalinowski
Copy link
Collaborator

Hi!, @sickill thanks for this! I have to ask @rolfb to sign the CLA https://developers.facebook.com/opensource/cla to credit him for this change (Facebook policy).

If that's a lot of hassle to him, then I'll close this PR and make this change myself - it will also apply to all current branches (0.9, 0.10, 1.0).
Otherwise @rolfb please let me know when you sign the CLA, so I can verify.

@ku1ik
Copy link
Author

ku1ik commented Apr 11, 2014

Update: I have noticed that with this change assets precompilation works fine but you can't start server nor console (in production env). Let's hold with merging this.

@rolfb
Copy link

rolfb commented Apr 13, 2014

Hi!

@sickill I updated the code so it only loads when using the assets group. Unicorns should like that.
@JakubMal I've signed the CLA for our Powow organization which includes me and @sickill (and some others).

@rolfb
Copy link

rolfb commented Apr 13, 2014

The build failed, so apparently using the group :assets is too exclusive?

@jtmalinowski
Copy link
Collaborator

Hi! @rolfb
What exactly is the problem with :group => :all ?
I'm not sure why it was not here in the first place, see e.g. https://github.com/emberjs/ember-rails/blob/master/lib/ember_rails.rb

@rolfb
Copy link

rolfb commented Apr 13, 2014

@sickill will have to elaborate on the why's on running server/console not starting in production. 

I'm off to bed. Revisiting tomorrow. 

Rolf

On Mon, Apr 14, 2014 at 1:17 AM, Jakub Malinowski
notifications@github.com wrote:

Hi! @rolfb
What exactly is the problem with :group => :all ?

I'm not sure why it was not here in the first place, see e.g. https://github.com/emberjs/ember-rails/blob/master/lib/ember_rails.rb

Reply to this email directly or view it on GitHub:
#40 (comment)

@ku1ik
Copy link
Author

ku1ik commented Apr 14, 2014

With both :group => :all and :group => :assets it gives me the following error when gem react-rails is only in the :assets group in Gemfile:

gitorious/mainline (43ba6ac*) % RAILS_ENV=production bundle exec rails c
/home/kill/.gem/ruby/1.9.3/gems/railties-3.2.17/lib/rails/railtie/configuration.rb:85:in `method_missing': undefined method `react' for #<Rails::Application::Configuration:0x0000000393f5c8> (NoMethodError)
        from /home/kill/code/gitorious/mainline/config/environments/production.rb:65:in `block in <top (required)>'
        from /home/kill/.gem/ruby/1.9.3/gems/railties-3.2.17/lib/rails/railtie/configurable.rb:24:in `class_eval'
        from /home/kill/.gem/ruby/1.9.3/gems/railties-3.2.17/lib/rails/railtie/configurable.rb:24:in `configure'
        from /home/kill/code/gitorious/mainline/config/environments/production.rb:1:in `<top (required)>'
        from /home/kill/.gem/ruby/1.9.3/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:251:in `require'
        from /home/kill/.gem/ruby/1.9.3/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:251:in `block in require'
        from /home/kill/.gem/ruby/1.9.3/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:236:in `load_dependency'
        from /home/kill/.gem/ruby/1.9.3/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:251:in `require'
        from /home/kill/.gem/ruby/1.9.3/gems/railties-3.2.17/lib/rails/engine.rb:576:in `block in <class:Engine>'
        from /home/kill/.gem/ruby/1.9.3/gems/railties-3.2.17/lib/rails/initializable.rb:30:in `instance_exec'
        from /home/kill/.gem/ruby/1.9.3/gems/railties-3.2.17/lib/rails/initializable.rb:30:in `run'
        from /home/kill/.gem/ruby/1.9.3/gems/railties-3.2.17/lib/rails/initializable.rb:55:in `block in run_initializers'
        from /home/kill/.gem/ruby/1.9.3/gems/railties-3.2.17/lib/rails/initializable.rb:54:in `each'
        from /home/kill/.gem/ruby/1.9.3/gems/railties-3.2.17/lib/rails/initializable.rb:54:in `run_initializers'
        from /home/kill/.gem/ruby/1.9.3/gems/railties-3.2.17/lib/rails/application.rb:136:in `initialize!'
        from /home/kill/.gem/ruby/1.9.3/gems/railties-3.2.17/lib/rails/railtie/configurable.rb:30:in `method_missing'
        from /home/kill/code/gitorious/mainline/config/environment.rb:5:in `<top (required)>'
        from /home/kill/.gem/ruby/1.9.3/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:251:in `require'
        from /home/kill/.gem/ruby/1.9.3/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:251:in `block in require'
        from /home/kill/.gem/ruby/1.9.3/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:236:in `load_dependency'
        from /home/kill/.gem/ruby/1.9.3/gems/activesupport-3.2.17/lib/active_support/dependencies.rb:251:in `require'
        from /home/kill/.gem/ruby/1.9.3/gems/railties-3.2.17/lib/rails/application.rb:103:in `require_environment!'
        from /home/kill/.gem/ruby/1.9.3/gems/railties-3.2.17/lib/rails/commands.rb:40:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'

When I move gem react-rails to default group it works fine. I believe putting this gem in a default group shouldn't be necessary (sass-rails works fine when put into :assets only).

This is all on Rails 3.2.17 app (Gitorious).

@jtmalinowski
Copy link
Collaborator

What's wrong with group: :all approach?
Can you compare our case against https://github.com/rails/sass-rails/blob/master/lib/sass/rails/railtie.rb#L40 ?

@jtmalinowski
Copy link
Collaborator

@sickill @rolfb
First of all: master is not production ready yet.

Second:
The problem is in your code, but the underlying reason is the unfortunate choice of not defaulting React's variant when it is not explicitly defined. You line #65 is:

config.react.variant = :production

And if you run RAILS_ENV=production bundle exec rails c with react-rails in assets group, then react-rails is not loaded, and config.reactis undefined.

Current master solves that with defaulting variant for React, also I think that the workaround you need is obvious.
I will apply group: :all to all branches soon. Should you need any help, let me know.

@rolfb
Copy link

rolfb commented Apr 16, 2014

Sounds good to me. Thanks Jakub. 

On ons., apr. 16, 2014 at 2:05 AM, Jakub Malinowski <notifications@github.com="mailto:notifications@github.com">> wrote:

@sickill @rolfb

First of all: master is not production ready yet.

Second:

The problem is in your code, but the underlying reason is the unfortunate choice of not defaulting React's variant when it is not explicitly defined. You line #65 is:

config.react.variant = :production

And if you run RAILS_ENV=production bundle exec rails c with react-rails in assets group, then it is not loaded, and config.reactis undefined.

Current master solves that with defaulting variant for React, also I think that the workaround you need is obvious.

I will apply group: :all to all branches soon. Should you need any help, let me know.


Reply to this email directly or view it on GitHub.

@dferrazm
Copy link

Is there any update on how to resolve this issue?

I'm not being able to run assets:precompile successfully on rails 3.2.17 using react-rails 0.10.

@jtmalinowski
Copy link
Collaborator

@dferrazm Could you check using 0.10 branch from github?
gem 'react-rails', git: 'git@github.com:reactjs/react-rails.git', branch: '0.10'

@jtmalinowski
Copy link
Collaborator

@dferrazm have you tried the solution I described?

@dferrazm
Copy link

dferrazm commented Jun 2, 2014

I managed to get it working by moving the gem out of the assets group and
setting config.assets.initialize_on_precompile = true
Em 02/06/2014 18:46, "Jakub Malinowski" notifications@github.com escreveu:

@dferrazm https://github.com/dferrazm have you tried the solution I
described?


Reply to this email directly or view it on GitHub
#40 (comment).

@jtmalinowski
Copy link
Collaborator

Sorry that I disappeared - I'll verify and close this soon. This gem cannot be in assets group only, and initialize_on_precompile was needed because the react's version was not inferred from environment version - this should not longer be the case but let me verify first.

@rmosolgo
Copy link
Member

I hope these problems are resolved with #187, please reopen if this is still an issue!

@rmosolgo rmosolgo closed this Mar 31, 2015
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.

6 participants