Reputation: 7257
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.
Upvotes: 3
Views: 1450
Reputation: 2916
Here is the optimized version:
<%= image_tag("user.png", class: "img-responsive", alt: "user image") %>
Upvotes: 3
Reputation: 1085
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
Upvotes: 4