I want to display the posted image
I was worried about the error in the situation that other than the image is displayed
ActionView::SyntaxErrorInTemplate in PrototypesController#index
Error location
Only the error part is described
<%= image_tag prototype.image, if prototype.image.attached? %>
At first there was a little more description, but I forgot.
The description that I referred to
<%= image_tag message.image, class: 'message-image' if message.image.attached? %>
The difference is that it contains classes.
I wrote it in the version without the class, but I got an error.
Do you know why you got the error?
It's not spelled differently.
Do you know what's different?
<%= image_tag prototype.image if prototype.image.attached? %>
The cause of the error statement is often simple, so it seems like when it was resolved.
When you're worried, it's hard to be honest.
But if you get over it, you can grow!
Keep it on.
You didn't need ",". I didn't use it when using the If statement, but I needed it when using the class.
"," Was a blind spot.
I thought it was necessary, so I learned that it is important to remove even the ones that I think are necessary.
Thank you!
Recommended Posts