我很好奇在使用zeitwerk进行自动加载的Rails6中,首选的命名空间代码应该是什么样子。 之前我使用的是: # app/controllers/api/users_controller.rb
module Api
class UsersController
def index
render json: {}
end
end
end 对于zeitwerk,我们现在应该使用:? # app/controllers/api/users_controller.rb
class Api::UsersController
def index
ren
这是一个简单的问题,但不知何故,我想不到答案。 在使用Zeitwerk迁移到Rails 6的过程中,我得到了: Please, check the "Autoloading and Reloading Constants" guide for solutions.
(called from <top (required)> at APP_ROOT/config/environment.rb:7)
rails aborted!
Zeitwerk::NameError: wrong constant name Enforce-calls-to-come-from-a
使用Rails 6
我有一个类似于so app/client/javascript/config/editor/syntax-highlighting的文件夹
里面有两个文件。
app/client/javascript/config/editor/syntax-highlighting/math-mode.js app/client/javascript/config/editor/syntax-highlighting/units-regex.js
当我部署到生产环境时,错误消息是:
Wrong constant name Syntax-Highlighting inferred by M
我使用了演示中的代码以及它们自己的作用域和表单工作。当我添加Materialize forms时,我注意到表单和过滤不再起作用。
显然filterrific没有加载它的javascript库(我为materialize加载了Jquery,它工作得很好)。
根据我的理解
//= require filterrific/filterrific-jquery
在assets中,/javascript/application.js将不起作用(也尝试过)。
我还得到了一个资产错误
Asset `filterrific/filterrific-spinner.gif` was not declared t
我在用Rails应用程序从经典的自动加载程序切换到Zeitwerk时遇到了一些麻烦,它在Rails 3天里看到了曙光--所以这里有一些外壳。
一些模型代码已被提取到模块中,并且这些模块嵌套在模型类(充当命名空间)中:
# app/models/donation
class Donation < ApplicationRecord
(...)
end
# app/models/donation/download
class Donation
module Download
def csv
(...)
end
end
end
然后在需要时动态使用这些
我目前在jobs目录中有以下文件:
# app/jobs/importer.rb
module Imporer
def self.valid_importers
# Do stuff
end
end
# app/jobs/importer/custom_import_job.rb
class Importer::CustomImportJob < ApplicationJob
def perform
# Do stuff
end
end
使用经典的代码加载器可以正常工作,但是当切换到Zeitwerk时,我在运行rails zeitwerk:check时得
我有Rails 6,我的预览类位于
mailer/previews/devise_mailer_preview.rb
class DeviseMailerPreview < ActionMailer::Preview
...
end
当我在本地运行应用程序时,一切都很顺利,我可以看到我在http://localhost:3000/rails/mailers/devise_mailer/confirmation_instructions地址上的电子邮件预览。但是现在我试图在服务器上部署应用程序,发现当我运行bundle exec rails c production时,我得到了错误: