Reputation: 381
I need to add the following attribute in my rails image_tag
data-zoom-image
I tried
<%= image_tag @post.uploads.first.upload.url(:medium), data: { :zoom-image => 'test'} %>
But throwing syntax error undefined local variable or method image.
How can I add attribute rails
Upvotes: 1
Views: 1520
Reputation: 19899
:zoom-image
isn't a valid symbol. You can't have a dash in there. You want this:
data: { zoom_image: 'test'}
or this:
data: { 'zoom-image' => 'test'}
In the both cases, Rails will output data-zoom-image="test"
into the HTML.
Upvotes: 4