Casper Nybroe
Casper Nybroe

Reputation: 1199

Using link_to with i18n and glyphicon, Ruby on Rails

I cant figure out how to use the link_to correctly with both internationalization tags and a glyphicon.

My code currently looks like this.

<%=link_to t('health_info.twitter_posts_featuredacc')+' <i class="fa fa-twitter"></i>'.html_safe, health_info_tweets_path(type: 'featured') %>

It pulls the correct translation but it also shows everything in the ''.html_safe as normal html code and not as the glyphicon.

Thanks in advance.

Upvotes: 1

Views: 294

Answers (1)

spickermann
spickermann

Reputation: 106802

I would use the block syntax for this:

<%= link_to(health_info_tweets_path(type: 'featured')) do %>
  <%= t('health_info.twitter_posts_featuredacc') %>
  <i class="fa fa-twitter"></i>
<% end %>

Upvotes: 2

Related Questions