Read more

Deal with error: Expected foo_trait.rb to define FooTrait

Dominik Schöler
June 28, 2012Software engineer at makandra GmbH

Lately, I came across a nasty error. I had a class Article that included FooTrait and BarTrait. In BarTrait, I then accidentally called a non-existent method:

has_defaults :dummy => Dummy.non_existent_method
Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

From that moment, no page would load anymore but always display an exception: Expected foo_trait.rb to define FooTrait. That trait had nothing to do with BarTrait.

Since it doesn't tell you what's wrong, you either remember where you were working last or you need to check all traits Show archive.org snapshot for mistakes.

This behavior is likely to be caused by Rails' autoloading.

Posted by Dominik Schöler to makandra dev (2012-06-28 09:56)