letter_opener_web: Rails 5: api mode - undefined method `assets`

Getting this for clear rails 5 api-only app (rails new myapp --api):

/home/oivai/.rvm/gems/ruby-2.3.0/bundler/gems/rails-513f72804d80/railties/lib/rails/railtie/configuration.rb:95:in `method_missing': undefined met
hod `assets' for #<Rails::Application::Configuration:0x000000047352b8> (NoMethodError)
Did you mean?  asset_host
        from /home/oivai/.rvm/gems/ruby-2.3.0/bundler/gems/letter_opener_web-55c581e463e7/lib/letter_opener_web/engine.rb:16:in `block in <class:E
ngine>'
        from /home/oivai/.rvm/gems/ruby-2.3.0/bundler/gems/rails-513f72804d80/railties/lib/rails/initializable.rb:30:in `instance_exec'
        from /home/oivai/.rvm/gems/ruby-2.3.0/bundler/gems/rails-513f72804d80/railties/lib/rails/initializable.rb:30:in `run'
        from /home/oivai/.rvm/gems/ruby-2.3.0/bundler/gems/rails-513f72804d80/railties/lib/rails/initializable.rb:55:in `block in run_initializers
'

Is there a workaround? Thank you!

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 16 (4 by maintainers)

Commits related to this issue

Most upvoted comments

The instruction found at rswag issue #12 worked for me. Try to uncomment require "sprockets/railtie" in config/application.rb and see if it works for you too!

I had the exact same issue installing activeadmin on rails5 --api, and uncommenting require "sprockets/railtie" in config/application.rb solved the problem

It is still reproducing for me. Rails 5.2.3 (API mode) letter_opener_web 1.3.4

undefined method assets' for #<Rails::Application::Configuration:0x0000562ec9be1128>

If I’m adding require 'sprockets/railtie' to application.rb, the next error I’m experiencing is

Expected to find a manifest file in `app/assets/config/manifest.js`

So I need to create this file. It’s not a good option for me, because I’m writing the application based on engines and completely don’t have app directory. Any ideas?

In the meantime, I added the following to my Gemfile:

gem ‘letter_opener_web’, github: ‘fgrehm/letter_opener_web’, ref: ‘d6c6455’

Thank you @flaviocamilo this solution still works!