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 trial
Derek Renfro
634 Pointstwo issues with ruby on rails
i am trying to code along with the beginner ruby on rails videos and i have come across two problems. when i am using twitter bootstrap for the fixed platform it is not working. i have wrapped the yield call with the container class but it is not doing anything. I am also having a problem of hiding the edit and delete button. i have put the code in to hide the admin class inside the coffee javascript file but there are not disappearing.
18 Answers
Enrico Della Monica
12,166 PointsHi Derek probably your problem resides in the file "statuses.css.scss" in the tutorial, something wrong it is been written (even if in the video everything works fine)
replace ."status.hover" with ".status:hover" it worked for me.
dean cameron
4,306 PointsI couldn't get the hide in coffeescript to work, either so i just ended up coding it in jQuery and putting it in my statuses.js.js file:
jQuery(document).ready(function() {
$('.status').hover(function () {
$(this).toggleClass("hover")
});
});
Joshua Ziggas
Courses Plus Student 2,641 PointsEnrico, I just spent three hours between google, stack exchange, etc because the jquery from that exercise was broken. Nothing seemed to help until I found your comment and now it all seems to be working, thank you! What is the difference between .status:hover and .status.hover, and what makes the latter broken?
Enrico Della Monica
12,166 PointsYou are welcome Joshua, .status.hover in this case does not make any sense. It is a class intersection. It's like saying : select a class which has both status and hover (class="status hover"). But we don't want that. In this case we want to select class="status" on a mouse hover event. So the correct way is .status:hover
Royce Negron
6,145 PointsI Don't know why my code isn't working for rails development: Installing Twitter Bootstrap. Treebook and Footer aren't showing up in the web browser like it shows in the video. Can anyone help with this?
<div class="container">
<h1>Treebook</h1>
<%= yield %>
<em>Footer</em>
</div>
Enrico Della Monica
12,166 Pointswhich video are you referring to? link please
Enrico Della Monica
12,166 Pointsin this video there is nothing like that. The code in application view is: <body> <h1>Treebook</h1> <%= yield %> <em>Footer</em> </body>
and it works just fine
rayorke
27,709 PointsHi Derek,
Would you be able to share some of the code that you're have trouble with?
Your application.html.erb should look similar to this when you wrap the yield:
...
<div class="container">
<%= yield %>
</div>
</body>
</html>
rayorke
27,709 PointsHmm. Strange. I was able to get it to work:
app/views/statuses/index.html.eb
<span class="admin">
| <%= link_to "Edit", edit_status_path(status) %> |
<%= link_to "Delete", status, method: :delete, data: { confirm: "Are you sure you want to delete this status?" } %>
</span>
app/assets/javascripts/statuses.js.coffee
$ ->
$('.status').hover (event) ->
$(this).toggleClass("hover")
Nice jQuery solution Dean! Always good to be able to code an alternative.
Derek Renfro
634 Pointshere is my application file
<!DOCTYPE html>
<html>
<head>
<title>Treebook</title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a href="#" class="brand"> Treebook </a>
<ul class="nav">
<li><%= link_to "All Statuses", statuses_path%>
</div>
</div>
</div>
<div class="container">
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
<%= yield %>
</div>
</body>
</html>
I have exactly what you have for my app/views/statuses/index.html.eb and my app/assets/javascripts/statuses.js.coffee files
Derek Renfro
634 Pointshow do a create a code block?
Derek Renfro
634 Pointsnevermind it i figured it out
rayorke
27,709 PointsIt looks like you're missing a few closing tags in the navbar. That may affect the rest of the page.
<!DOCTYPE html>
<html>
<head>
<title>Treebook</title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a href="#" class="brand"> Treebook </a>
<ul class="nav">
<li><%= link_to "All Statuses", statuses_path%></li>
</ul>
</div>
</div>
</div>
<div class="container">
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
<%= yield %>
</div>
</body>
</html>
Derek Renfro
634 Pointsawesome thanks that fixed my container issue but i am still having the issue with the hover. how do i go about the creating the jquery file? or is that covered in a later video?
rayorke
27,709 PointsGlad it worked for you!
I don't believe the video covers it using jQuery. Dean just came up with his own solution.
If you want to work through the coffeescript - feel free to post up your code for that - otherswise, perhaps Dean could offer some insight into jQuery instead.
Derek Renfro
634 Pointshere is my coffee script
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
$ ->
$('.status').hover (event) ->
$(this).toggleClass("hover")
rayorke
27,709 PointsHmm, it seeems correct. So, unless there is an error in your index.html.erb, I'm at a loss.
David A
4,410 PointsThanks Enrico! You fixed it for me too.
Enrico Della Monica
12,166 Pointsyou are welcome
Cameron Incoll
1,207 Pointsfixed for me too - weird thing is that it was working in development, then had trouble getting bootstrap working in production - once I got bootstrap working in production then the hover stopped working in development and kept working in production.
it's like a different version of the gem was installed or something?
Nithin Kumar
5,383 PointsThis helped me as well...
Nirmesh Patel
Courses Plus Student 221 PointsThanks Enrico !!
Peter Peng
1,156 PointsPeter Peng
1,156 PointsThanks! This worked for me :)
Enrico Della Monica
12,166 PointsEnrico Della Monica
12,166 Pointsyou're welcome