-
Notifications
You must be signed in to change notification settings - Fork 462
Closed as not planned
Description
Steps to reproduce
- put
image.png
inapp/assets/images/image.png
- create an example component that accepts an
image
argument, with a preview file - in the preview file, add
render ExampleComponent.new(image: image_path("image.png")
- this will trigger a
NoMethodError
- add
include ActionView::Helpers::AssetUrlHelper
at the top of the preview class
class ExampleComponent < ApplicationComponent
def initialize(image:)
@image = image
end
def call
image_tag @image
end
end
class ExampleComponentPreview < ViewComponent::Preview
include ActionView::Helpers::AssetUrlHelper
def default
render(ExampleComponent.new(image: image_path("image.png")))
end
end
Expected behavior
The preview renders the image with path /assets/image-80b04a6277839296f66f0e7de1fb03a3061322fad2273b18a375bf2f5381c41f.png
.
Actual behavior
The preview renders but the image path is /images/image.png
.
System configuration
Rails version: 6.1.4.1
Ruby version: 2.7.4
Gem version: 2.40.0
joshmfrankel
Metadata
Metadata
Assignees
Labels
No labels