0

Running a newly installed Rails 5 beta 3 with Ruby 2.2.3. Added react-rails 1.6.0 in the gem file then bundle install.

Installed then rails s. Then error:

Users/sylar/.rvm/gems/ruby-2.2.3/bundler/gems/rails-442207387e62/railties/lib/rails/railtie/configuration.rb:95:in method_missing': undefined methodassets' for # (NoMethodError)

Is this a react-rails issue or rails 5 itself? Works ok in Rails 4.2.5.

Sylar
  • 11,422
  • 25
  • 93
  • 166

2 Answers2

0

It seems as if rails 5 --api has require "sprockets/railtie" commented out. Uncommented and all is well. This was found in config/application.rb

Sylar
  • 11,422
  • 25
  • 93
  • 166
0

This was not an option when you posted your question, but if you didn't manage to get react-rails working (and for anyone else with the same problem)...I was seeing the same error, but was able to fix it with the following steps:

  1. Update Rails 5 beta 3 to the release version, and include react-rails in the Gemfile:

    gem 'rails', '~> 5.0.0'
    gem 'react-rails' # use whatever version you want here.
    
  2. Run these terminal commands in the project root line:

    bundle install
    rails g react:install
    

At this point, a new error appeared when running rails s - then once I'd fixed that, a browser error showed up. I was able to fix everything with a few additional steps:

  1. Add the following to app/assets/javascripts/application.js. If you are using require_tree ., ensure you place it before this line:

    //= require react
    //= require react_ujs
    //= require components
    //= require_tree .
    
  2. Create app/assets/javascripts/components/components.js.

  3. Add this line to config/assets.rb:

    Rails.application.config.assets.paths << "#{Rails.root}/app/assets/javascripts/components"
    

At this point I had react-rails working.

Hopefully that helps.

Andrew Faulkner
  • 3,662
  • 3
  • 21
  • 24