我有一个 Rails 引擎和 Rails 应用程序,都运行 Rails 6.0.0.rc1。
引擎定义带有 ActiveStorage 附件的模型,例如。
module Shop
class Product < ApplicationRecord
...
has_one_attached :image
has_many_attached :images
end
end
在引擎和应用程序视图中使用此模型并尝试调用= url_for(product.image)
会引发异常undefined method 'attachment_path' for #<#<Class:XXX>:XXX>
。product.image.attached?
返回 true,因此附件可用。
这段代码是从 Rails 应用程序中提取的,它工作得很好。是否有用于 Rails Engine 模型附件的特殊路由助手或rails active_storage:install
文档中未提及的其他设置?