Skip to content

Error with Rails 5 in production env #403

@renchap

Description

@renchap

Rails 5 : rails/rails@472b8e0
react-rails : 290765a
Sprockets : rails/sprockets@c8b96cd

When deploying in the production env, I get this error :

NoMethodError: undefined method `[]' for nil:NilClass
File ".../bundle/ruby/2.2/bundler/gems/react-rails-290765a1ac14/lib/react/server_rendering/sprockets_renderer.rb" line 14 in block in initialize
File ".../bundle/ruby/2.2/bundler/gems/react-rails-290765a1ac14/lib/react/server_rendering/sprockets_renderer.rb" line 13 in each
File ".../bundle/ruby/2.2/bundler/gems/react-rails-290765a1ac14/lib/react/server_rendering/sprockets_renderer.rb" line 13 in initialize
File ".../bundle/ruby/2.2/bundler/gems/react-rails-290765a1ac14/lib/react/server_rendering.rb" line 22 in new
File ".../bundle/ruby/2.2/bundler/gems/react-rails-290765a1ac14/lib/react/server_rendering.rb" line 22 in create_renderer
File ".../bundle/ruby/2.2/bundler/gems/react-rails-290765a1ac14/lib/react/server_rendering.rb" line 12 in block in reset_pool

The error occurs here :

js_code << ::Rails.application.assets[filename].to_s

After looking in the console, Rails.application.assets is empty in this environment. Setting config.assets.compile = true in config/environments/production.rb fixes the issue.

I dont really know how this can be fixed otherwise, this is my first try at react / react-rails.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions