trailblazer / trailblazer-loader

Require concept files, models and more without any autoloading magic.
MIT License
17 stars 23 forks source link

Representers not properly autoloaded using trailblazer #23

Open HoneyryderChuck opened 6 years ago

HoneyryderChuck commented 6 years ago

I'm defining representers in the nested-plural way. So I have the following representer:

# app/concepts/users/representer/user_representer.rb
class UserRepresenter < Representable::Decorator
  property :name
  collection :tax_residencies, decorator: TaxResidencyRepresenter
end

# app/concepts/tax_residencies/representer/tax_residency_representer.rb
class TaxResidencyRepresenter < Representable::Decorator
...
end

When I try to run any of my rails-defined tasks, for db or running specs, I get this error:


 uninitialized constant UserRepresenter::TaxResidencyRepresenter

my "quick-fix" was to add the following line above the user representer definition:

require_dependency Rails.root.join("app", "concepts", "tax_residencies", "representer", "tax_residency_representer")

but I think this is broken behaviour, indicating a bug in the loader logic.