Reputation: 28586
I'm trying to make link_to function have a css class attached to it,
My code is something like this:
<%= link_to newGame do%>
<%= image_tag newGame.image_url.to_s %>
<% end %>
which links an image to its content, but I need to add a class="thumbnail" to the link,
ie:
<a href="/games/:id" class="thumbnaill>
instead of what its currently generating:
<a href="/games/:id">
Thanks
Upvotes: 1
Views: 1369
Reputation: 47532
Ref link_to
<%= link_to newGame, class: 'thumbnail' do %>
Be careful when using the older argument style, as an extra literal hash is needed:
<%= link_to "Articles", { :controller => "articles" }, :id => "news", :class => "article" %>
#Gives <a href="/articles" class="article" id="news">Articles</a>
Upvotes: 1
Reputation: 3371
You can just do
<%= link_to newGame, class: 'thumbnail' do %>
<%= image_tag newGame.image_url.to_s %>
<% end %>
Upvotes: 0