Search code examples
ruby-on-railsglyphicons

how to add 'glyphicon glyphicon-user' and 'glyphicon glyphicon log-in' in this code?


My code which is coming wrong: This is what i have tried but it is coming wrong

<ul class="nav navbar-nav navbar-right">
  <li> <span class="glyphicon glyphicon-user"> <%= link_to 'SignUp',   {:controller =>'users', :action => 'new'} %></span> </li>
  <li> <span class="glyphicon-log-in"> <%= link_to 'LogIn', {:controller =>'sessions', :action => 'new'} %></span> </li>
</ul>

Solution

  • Try this:

    <ul class="nav navbar-nav navbar-right">
      <li> <%= link_to raw('<span class="glyphicon glyphicon-user"></span>'),   {:controller =>'users', :action => 'new'} %> </li>
      <li> <%= link_to raw('<span class="glyphicon glyphicon-log-in"></span>'), {:controller =>'sessions', :action => 'new'} %> </li>
    </ul>
    

    Your links should wrap your icons, not the other way around. If it's still not working, it's likely due to you not including the relevant icon font or css files correctly in your project. If it's still not working, update your question with a screenshot of what it looks like, and also the relevant code where you're including Bootstrap's css and fonts.