React_on_rails: undefined method `assets' for #<Rails::Application::Configuration:0x007fd97c239e90>

Created on 24 May 2016  路  2Comments  路  Source: shakacode/react_on_rails

Hey all -

I'm trying to install this for the first time on an existing Rails app but I'm getting

/Users/chintanparikh/.rvm/gems/ruby-2.3.1/gems/railties-5.0.0.rc1/lib/rails/railtie/configuration.rb:95:inmethod_missing': undefined method assets' for #<Rails::Application::Configuration:0x007fd97c239e90>

I'm not too sure why - I'm definitely not running Rails in API-only mode.

Here's my assets.rb (where it's erroring out).

# Be sure to restart your server when you modify this file.

# Version of your assets, change this if you want to expire all your assets.
#Rails.application.config.assets.version = '1.0'

# Add additional assets to the asset load path
# Rails.application.config.assets.paths << Emoji.images_path

# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# Rails.application.config.assets.precompile += %w( search.js )
# Add client/assets/ folders to asset pipeline's search path.
# If you do not want to move existing images and fonts from your Rails app
# you could also consider creating symlinks there that point to the original
# rails directories. In that case, you would not add these paths here.


# NOTE MOVED THIS ALL INTO APPLICATION.RB

# Rails.application.config.assets.precompile += %w( server-bundle.js )

# Add folder with webpack generated assets to assets.paths
# Rails.application.config.assets.paths << Rails.root.join("app", "assets", "webpack")


Rails.application.config.assets.precompile += %w( server-bundle.js )
Rails.application.config.assets.paths << Rails.root.join("app", "assets", "webpack")

type = ENV["REACT_ON_RAILS_ENV"] == "HOT" ? "non_webpack" : "static"

Rails.application.config.assets.precompile +=
  [
    "application_#{type}.js",
    "application_#{type}.css"
  ]

And my development.rb

Rails.application.configure do
  config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
  # Settings specified here will take precedence over those in config/application.rb.

  # In the development environment your application's code is reloaded on
  # every request. This slows down response time but is perfect for development
  # since you don't have to restart the web server when you make code changes.
  config.cache_classes = false

  # Do not eager load code on boot.
  config.eager_load = false

  # Show full error reports.
  config.consider_all_requests_local = true

  # Enable/disable caching. By default caching is disabled.
  if Rails.root.join('tmp/caching-dev.txt').exist?
    config.action_controller.perform_caching = true

    config.action_mailer.perform_caching = false

    config.cache_store = :memory_store
    config.public_file_server.headers = {
      'Cache-Control' => 'public, max-age=172800'
    }
  else
    config.action_controller.perform_caching = false

    config.action_mailer.perform_caching = false

    config.cache_store = :null_store
  end

  # Don't care if the mailer can't send.
  config.action_mailer.raise_delivery_errors = false

  # Print deprecation notices to the Rails logger.
  config.active_support.deprecation = :log

  # Raise an error on page load if there are pending migrations.
  config.active_record.migration_error = :page_load

  # Debug mode disables concatenation and preprocessing of assets.
  # This option may cause significant delays in view rendering with a large
  # number of complex assets.
  #config.assets.debug = true

  # Asset digests allow you to set far-future HTTP expiration dates on all assets,
  # yet still be able to expire them through the digest params.
  #config.assets.digest = true

  # Adds additional error checking when serving assets at runtime.
  # Checks for improperly declared sprockets dependencies.
  # Raises helpful error messages.
  #config.assets.raise_runtime_errors = true

  # Raises error for missing translations
  # config.action_view.raise_on_missing_translations = true

  # Use an evented file watcher to asynchronously detect changes in source code,
  # routes, locales, etc. This feature depends on the listen gem.
  config.file_watcher = ActiveSupport::EventedFileUpdateChecker
end

Here's my Gemfile:

source 'https://rubygems.org'

ruby '2.3.1'
gem 'rails', '~> 5.0.0.rc1'
gem 'pg'
gem 'therubyracer', platforms: :ruby
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'listen'
gem 'kaminari'
gem "paperclip"
gem 'dotenv-rails'
gem 'swagger-docs'
gem "react_on_rails", "~> 5"


# For Authentication
gem 'devise'

group :development, :test do
  gem 'byebug'
end

group :development do
  gem 'web-console', '~> 2.0'
  gem 'spring'
end

gem 'rails_12factor', group: :production

I'm not too sure where to start debugging this - any help would be appreciated!

Most helpful comment

Turns out I did have the asset pipeline disabled - fixed it by adding the appropriate gems back in. In case anyone comes across this in the future, I needed the following in my gemfile:

# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 2.7.2'

# Use jquery as the JavaScript library
gem 'jquery-rails'

All 2 comments

@chintanparikh Please use v6 rc.X of react on Rails and compare your setup to https://github.com/shakacode/react-webpack-rails-tutorial/ and let me know what you find.

Turns out I did have the asset pipeline disabled - fixed it by adding the appropriate gems back in. In case anyone comes across this in the future, I needed the following in my gemfile:

# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 2.7.2'

# Use jquery as the JavaScript library
gem 'jquery-rails'
Was this page helpful?
0 / 5 - 0 ratings

Related issues

hakunin picture hakunin  路  3Comments

chintanparikh picture chintanparikh  路  5Comments

axhamre picture axhamre  路  8Comments

justin808 picture justin808  路  7Comments

risinglf picture risinglf  路  3Comments