Questions tagged [zeitwerk]

68 questions
0
votes
1 answer

Zeitwerk? Ruby on Rails ::Domains::Article => /app/domains/domains/ariticle.rb

I have domain logic code stored in app/domains/domains/article.rb The class is class Domains::Article end It bothers me that the proper loading structure is app/domains/domains/article.rb and not app/domains/article.rb Does anyone know what the…
Daniel
  • 7,006
  • 7
  • 43
  • 49
0
votes
1 answer

Rails Zeitwerk loads modules 'partial'? ie. my Module calls 'extend OtherModule', but the rest of the module in the file is ignored

Intro: I am migrating my application from Rails 3.2.x to Rails 7.0.4.2. I am much more far already, than I expected. Although I am a zeitwerk noob, I like that approach - especially the "no require" part. To be sure, that I do not have any requires…
halfbit
  • 3,773
  • 2
  • 34
  • 47
0
votes
2 answers

Looking for a more granular way to organize Rails models and understanding autoloader

In a test application (Rails 7.0, Ruby 3.2) I'm currently experimenting with a different structure of models than the default. The idea was to have something like this where all related code of a model lives together and each group uses same naming…
floriansuchan
  • 255
  • 4
  • 13
0
votes
1 answer

Rails 7.x and Zeitwerk seems to load / find nothing? What did I forget?

I have an old Rails 3.x application that I now migrate to 7.x (It is/was already running under 5.0, so it is not so hard). However, I planed to do this step by step, but it is more or less impossible to install older versions 2023. The application…
halfbit
  • 3,773
  • 2
  • 34
  • 47
0
votes
1 answer

Push single file to Zeitwerk loader

For a Roda app, I'd like to include a single file for autoloading by Zeitwerk while ignoring all the others in that directory. The simplified layout looks like this: config application.rb puma.rb (...) lib my_class.rb (...) To setup…
svoop
  • 3,318
  • 1
  • 23
  • 41
0
votes
2 answers

Uninitialized constant for Rails 6 with Zeitwerk

I'm upgrading my Rails app from v5 to v6. The files are structured as: lib |- container |- my_module_a | |- my_class.rb | |- class_two.rb |- my_module_b my_module directory has no files in it, only my_module_a and my_module_b…
valk
  • 9,363
  • 12
  • 59
  • 79
0
votes
2 answers

Unable to load classes/modules with Zeitwerk on Ruby project

I have built a Ruby project and I want to switch from using a ton of require_relative statements to a smarter autoloader like Zeitwerk. There are a lot of files/folders in the project, hence I will only present some of them in order to not make my…
0
votes
1 answer

Upgrading Rails, how to autoload constants before config/environment/devlopment.rb runs?

I'm new to Ruby and Rails, so please forgive me if this is a n00b question. I'm trying to upgrade a very old app (using Ruby 2.3.4 and Rails 5.0.6) to the latest versions of Ruby (3.1.3) and Rails (7.0.4). When config/environment/devlopment.rb…
0
votes
1 answer

Uninitialized constant after upgrade rails 5.2 to 6.0

After upgrading my RoR app to 6.0, I'm getting this error: NameError: uninitialized constant Sites::NetworkResolver::ExternalApi. This is my app/resolvers/sites/network_resolver.rb file: module Sites class NetworkResolver ExternalApi::Graphql …
0
votes
0 answers

Controller concern constant not being loaded by model concern in production

Legacy rails app that's been upgraded to v6.0.5.1 - Zeitwerk enabled I have a controller concern. I.e. # /app/controllers/concerns/example.rb module Example extend ActiveSupport::Concern CONSTANT = [1, 2, 3].freeze end and a model concern that…
Ben Garcia
  • 376
  • 2
  • 11
0
votes
1 answer

Rails Zeitwerk not respecting class in a module

Running rails zeitwerk:check returns expected file app/api/mariana_tek_client.rb to define constant MarianaTekClient The odd thing is that I have the following class defined in this file, which seems to follow the convention that I've seen…
0
votes
0 answers

Zeitwerk + Rails 6.1 - controller modules not autoloading

I'm working with a legacy app with controllers where the basic CRUD actions are split into modules. The modules are within the app/controllers folder and each module is separately included in the controller class. (Yes, it's because the modules are…
nimmolo
  • 191
  • 3
  • 14
0
votes
2 answers

Zeitwerk collapse namespacing to root level

Zeitwerk's readme gives this example for collapsing namespaces: booking.rb -> Booking booking/actions/create.rb -> Booking::Create To make it work that way, configure Zeitwerk to collapse said…
Mirror318
  • 11,875
  • 14
  • 64
  • 106
0
votes
0 answers

Zeitwerk: add custom namespace to /public directory

I have an app with the following structure: - my_app - bin - config - packages - pack_name - priv - public - service_one - service_two - other_pack_name Note there is no app dir, because I'm using…
ntonnelier
  • 1,539
  • 3
  • 23
  • 49
0
votes
1 answer

Zeitwerk constant missing when class moved into nested /public dir

I'm refactoring here a classic Rails app into a packages/modularized structure using packwerk. So what used to be: - app - services - foo turned into: - packages - package_name - services - foo I added the following line in…
ntonnelier
  • 1,539
  • 3
  • 23
  • 49