Ada*_*ček 1 ruby-on-rails rails-engines rails-activestorage ruby-on-rails-6
我有一个 Rails 引擎和 Rails 应用程序,都运行 Rails 6.0.0.rc1。
引擎使用 ActiveStorage 附件定义模型,例如。
module Shop
class Product < ApplicationRecord
...
has_one_attached :image
has_many_attached :images
end
end
Run Code Online (Sandbox Code Playgroud)
在引擎视图和应用程序视图中使用此模型并尝试调用= url_for(product.image)会引发异常undefined method 'attachment_path' for #<#<Class:XXX>:XXX>。product.image.attached?返回 true,因此附件可用。
这段代码是从 Rails 应用程序中提取的,它运行得很好。是否有针对 Rails Engine 模型附件的特殊路线助手或rails active_storage:install文档中未提及的除所需之外的任何设置?
| 归档时间: |
|
| 查看次数: |
1282 次 |
| 最近记录: |