Questions tagged [zeitwerk]

68 questions
1
vote
1 answer

Rails 6 + Zeitwerk, loading files without class

We are upgrading to Rails 6, and have done most of the work to make our application work with Zeitwerk. We do have two files, which are query objects, existing under app/queries and we don't define a class for them. They exists with methods…
MC Mowgli
  • 113
  • 7
1
vote
0 answers

Uninitialized constant WebHook::Endpoint when running zeitwerk test

I've recently started the upgrading process of my app to use Rails 6. Some of it is very smooth, some of it not. The problem I am facing right now is that in a factory bot we define: factory :webhook_endpoint, class: Webhook::Endpoint do …
MC Mowgli
  • 113
  • 7
1
vote
2 answers

Zeitwerk fails in production loading custom SimpleNavigation renderer

Getting ready for Rails 7 by shifting to Zeitwerk autoloader (Rails 6.1.4.4 on Ruby 2.7.5). Turned off the config.autoloader = :classic line in application.rb. App is loading 6.1 defaults. Dev mode runs fine, but production fails on boot (also fails…
John Athayde
  • 580
  • 2
  • 13
1
vote
2 answers

Rails Zeitwerk snakecase

When we have a directory under app/ that we want Zeitwerk to work off of, and say that naming happens to be something like app/stuff/graphql.rb app/stuff/graphql_error.rb then Zeitwerk is looking for some module Stuff that has some module or class…
David Lazar
  • 10,865
  • 3
  • 25
  • 38
1
vote
1 answer

Why object_id changes after app initialization?

Rails 6.1.4.1 I'm setting values from an initializer file and when I request a page, I find the object_id of the configuration changed (and the values lost) unless I do require 'my_library' in the initializer file. I don't understand…
yoones
  • 2,394
  • 1
  • 16
  • 20
1
vote
0 answers

Error while running rake zeitwerk:check in a model by inheriting a class from a rails engine as a gem in Rails 6 app using Zeitwerk Loader

I am using a Rails Engine as a Gem in my Rails Application. Now I have inherited a class from the rails engine in a model of my rails app. 1. Rails App Model Code class AppModelOne < EngineGem::EngineClassOne # body of the class end But while…
Supriyo Mahanta
  • 233
  • 1
  • 3
  • 11
1
vote
2 answers

Can't customize inflection (ID)

The controller: # app/controllers/v1/nem_id_controller.rb class V1::NemIDController < ApplicationController end I created an initializer to customize the inflection: # config/initializers/zeitwerk.rb Rails.autoloaders.each do |autoloader| …
David
  • 97
  • 9
1
vote
3 answers

Zeitwerk error on devise mailer in production environment

I have Rails 6, my preview class located in mailer/previews/devise_mailer_preview.rb: class DeviseMailerPreview < ActionMailer::Preview ... end And when I run application locally, everything is going fine, I can see my email previews on…
Ruslan Valeev
  • 1,529
  • 13
  • 24
1
vote
1 answer

Cannot auto-load class in Rails6

I want to add custom class to app folder into clean Rails 6 project, ruby 2.7.0. According to Zeitwerk documentation it should auto-load all paths under app directory. app/custom/car.rb class Car def self.print print 'Car' end end I'm…
1
vote
2 answers

Rails 6 Zeitwerk unloads my class after initializer

I am implementing a singleton class/module in Rails 6 application using Zeitwerk loader. # app/lib/mynamespace/mymodel.rb module Mynamespace module Mymodel class << self attr_accessor :client end def self.client @client…
Max Ivak
  • 1,529
  • 17
  • 39
1
vote
1 answer

rails 6 app tests green but in production wierd effect: LoadError (cannot load such file -- rb-readline)

Deploying a rails 6 app which has tested green. Expected same behaviour in production after deployment as in production, of course. However, in production, when starting, fails with the following result: LoadError: cannot load such file --…
willyab
  • 167
  • 1
  • 10
0
votes
1 answer

'Zeitwerk::SetupRequired' error on rails. What does it mean?

I got the error "Zeitwerk::SetupRequired: please, finish your configuration and call Zeitwerk::Loader#setup once all is ready" while browsing my locally running rails app. (Rails v6.0.6) What does this mean and how do I fix it? Only part of the app…
Harry Wood
  • 2,220
  • 2
  • 24
  • 46
0
votes
0 answers

Adding a administrate gem gives Zeitwerk error

I am getting a error Error: expected file /Users/luqman/Desktop/Checkout/jcom .app/app/dashboards/sessions_dashboard.rb to define constant SessionsDashboard, but didn't When I try to run rails g administrate:install My sessions controller is #…
0
votes
1 answer

How to configure Zeitwerk to work with acronym inflections?

My Rails app is using an engine that defines an acronym inflection: ActiveSupport::Inflector.inflections(:en) do |inflect| inflect.acronym "UI" end This means (for example) that Rails will load UIHelper from helpers/ui_helper.rb rather than…
Kyle Fox
  • 3,133
  • 4
  • 23
  • 26
0
votes
0 answers

Switch autoloader from Classic to Zeitwerk

I'm currently updating a 5.2 Rails project to 6.0, and I have problems with Zeitwerk. The web application consists of 3 Rails websites (Private, Public and Backoffice) and 1 gem (named kiosk) that contain an engine that contain common parts for the…
Mickael_S
  • 1
  • 1