I want to add class to img_tag in rails application.
<%= image_tag("user.png"), :class => "img-responsive" %>
Here i have added class img-responsive to the image.
but i am getting error if i add this statement in line. i am not able to figure out what is missing in above line.
the error is:
app/views/pages/user_dashboard.html.erb:21: syntax error, unexpected ',', expecting ')'
How to resolve this issue.
You have to put the class attributes inside the bracket . Like <%= image_tag("user.png", :class => "img-responsive") %> Hope this will solve your problem . Have a great day
Here is the optimized version:
<%= image_tag("user.png", class: "img-responsive", alt: "user image") %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With