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

Ruby

two 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

Hi 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.

Thanks! This worked for me :)

you're welcome

I 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")
    });
});

Enrico, 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?

You 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

http://www.w3schools.com/cssref/sel_hover.asp

I 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>

which video are you referring to? link please

in 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

Hi 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>

Hmm. 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.

here 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

how do a create a code block?

nevermind it i figured it out

It 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>

awesome 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?

Glad 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.

here 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")

Hmm, it seeems correct. So, unless there is an error in your index.html.erb, I'm at a loss.

Thanks Enrico! You fixed it for me too.

you are welcome

fixed 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?

This helped me as well...

Thanks Enrico !!