我有名为 hanami 1.3.0 的应用程序booking。有 rake 任务/rakelib/motel.rake:
require_relative '../lib/booking' # it requires booking/motel/booker file
namespace :motel do
task :book do
Booking::Motel::Booker.new.book
end
end
booking/motel/booker需要 booking_repository 文件,并尝试实例化 BookingRepository,但失败并出现错误:
NameError: uninitialized constant Hanami::Repository
<root>/lib/booking/repositories/booking_repository.rb:1:in <top (required)>'
但是,当我在 hanami 控制台中运行时,它可以毫无问题Booking::Motel::Booker.new.book地加载。BookingRepository
查看了许多有关 hanami rake 的堆栈问题,但找不到答案。