ryanb / letter_opener

Preview mail in the browser instead of sending.
MIT License
3.71k stars 236 forks source link

fix "undefined method `root'" on standalone with activemodel #152

Closed centrevillage closed 6 years ago

centrevillage commented 6 years ago

Hello.

I found a problem for using letter_opener with standalone mode.

My Gemfile is this:

gem 'activesupport', '~> 5.1.6'
gem 'actionmailer', '~> 5.1.6'
gem 'letter_opener'

When mail is sent, this error occurred:

vendor/bundle/ruby/2.3.0/gems/letter_opener-1.6.0/lib/letter_opener/configuration.rb:6:in `initialize': undefined method `root' for Rails:Module (NoMethodError)
nashby commented 6 years ago

Hey, that's kinda strange that you have Rails constant defined but don't have root method. Can you please upload sample app that reproduce this issue?

centrevillage commented 6 years ago

https://github.com/centrevillage/letter_opener_sample

bundle install
bundle exec ruby app.rb
nashby commented 6 years ago

@centrevillage thank you for the patch and thanks for providing sample application! Awesome first contribution to the project, cheers! ❤️