Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialDaniel Roman
2,867 PointsI trying to create a nice button using bootstrap
I'm working on my buttons and somehow this is not working at all. The line code I'm changing looks like this:
<td><%= link_to "Details", controller: "companies", action: "show", id: sbr.id %>
And I'm adding btn btn-primary to make it look nice but nothing happens;
<td><%= link_to "Details", controller: "companies", action: "show", id: sbr.id, class: "btn btn-success" %>
Any Ideas
3 Answers
Seth Kroger
56,413 PointsI had to look this up but if you are using the controller/action syntax instead of a route with the html options it needs to be in its own hash like:
<td><%= link_to "Details", {controller: "companies", action: "show"}, id: sbr.id, class: "btn btn-success" %>
See the API docs for link_to, in the middle of the examples section. http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to
Daniel Roman
2,867 PointsI tried but it gives me an error like this: No route matches {:action=>"show", :controller=>"companies"}
Ralph Cacho
8,698 PointsHello Ivan,
Make sure you have the Bootstrap library included in your project. The easiest way to do this is using their Bootstrap CDN (mentioned at http://getbootstrap.com/getting-started/):
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
Once you have that included, you should be able to use it like this:
<button class="btn btn-primary">Send</button>
Let us know if that helps. Good luck!
Daniel Roman
2,867 Pointsboot strap is working and the link does work and I just can't figure why the btn would appear on page do I have type it in different way?
Daniel Roman
2,867 PointsMr, Kroger bootstrap is working and I didn't know there was a gem for bootstrap?
Seth Kroger
56,413 PointsSeth Kroger
56,413 PointsI've edited your post for formatting.
Does bootstrap work otherwise in your app? Did you include the gem for it in the gemfile and have no trouble installing it?