Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7904269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:58:52+00:00 2026-06-03T09:58:52+00:00

I am working through the Agile Web Development with Rails book but I have

  • 0

I am working through the Agile Web Development with Rails book but I have been using Twitter Bootstrap instead of the custom styling from the book. I am having trouble adding an icon through GLyphonics to the button_to method. My code looks like this:

<%= button_to <i class="icon-search icon-white">Add To Cart</i>, 
              line_items_path(product_id: product), 
              class: "btn btn-success" %>

I have tried quite a few variations but can’t seem to get it to work correctly.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T09:58:54+00:00Added an answer on June 3, 2026 at 9:58 am

    It looks like you have an issue with your quotes:

    <%= button_to raw("<i class=\"icon-search icon-white\">Add To Cart</i>"), 
              line_items_path(product_id: product), 
              class: "btn btn-success" %>
    

    Enclose the label of the button in double quotes, escape the double quotes in your i tag, and finally, wrap everything into a raw() call to ensure the HTML is properly displayed.

    Alternatively you can use html_safe:

    <%= button_to "<i class=\"icon-search icon-white\">Add To Cart</i>".html_safe, 
              line_items_path(product_id: product), 
              class: "btn btn-success" %>
    

    good point from @jordanpg: you can’t have HTML in the value of a button, so his solution is more appropriate and should get the approved status.
    the html_safepart remains valid though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just working through the Agile Web Development with Rails book and near the closing
I'm working through Agile Web Development with Rails and having a problem with Task
I'm working my way through Agile Web Development with Rails and am running into
I'm working through Agile Web Development with Rails, Edition 4 with some tweaks (mostly
Working through Agile Web Development with Rails edition 4 and hit the section on
I'm working through Agile Web Dev w/ Rails book (4th ed) and I'm totally
I am working through the Ruby on Rails 3 tutorial book and typed the
So right now I'm learning Ruby on Rails, and I'm working through the book
I'm working through Aaron Hillegass' book, specifically the lottery example. I had a question
I've recently been working through a large codebase, refactoring and generally improving design to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.