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

With Odot when I click "List Items" from the Todo List page, the whole database is displayed on screen. How to remove?

HI I'm doing the Rails course with Odot and I'm trying to figure out how to remove extra database items information that are being displayed on the screen.

Here is an inline image screen shot of my page

If that image doesn't work, basically, the regular Odot list items are being displayed with what looks like the relational database on top of the table.

What file should I look at to see why the database is being shown on the page. I looked at the View file "index.html.erb" and it looked just like what was in the lesson. Although I could have missed a little character somewhere. Would that even be the right place to look in remedying this issue? What other files could affect what's displayed in the Todo Items page?

I hope there is enough information here, I'm very interested in finding the answer, so if anyone needed more info, I'll be sure to provide it as soon as I see it.

Thanks,

Jason

3 Answers

Robert Ho
PLUS
Robert Ho
Courses Plus Student 11,383 Points

Hey Jason,

The reason you are seeing all an array of your ActiveRecord todo_items is because you have an EQUAL sign in your erb code.

    Equal sign there ~~~~~>  <%= @todo_list.todo_items.each do |todo_item| %>

Having the equal sign in the erb code will output the results of the code into the HTML. If do not want to output the code, take out the equal sign like this:

    No more equal sign there ~~~~~>  <% @todo_list.todo_items.each do |todo_item| %>

And that should solve your problem.

For reference:

http://stackoverflow.com/questions/7996695/rails-erb-syntax

Good luck!

Robert Ho
PLUS
Robert Ho
Courses Plus Student 11,383 Points

Can you post your code for the View (index.html.erb)? It looks like the top part is calling only the ActiveRecord object's that represent your TodoItem model itself and not their attributes.

Sure! the file path is odot/app/views/todo_items/index.html.erb and I pasted in the code below. Thanks for your help!

<h1><%= @todo_list.title %></h1>

<table class="todo_items">
    <%= @todo_list.todo_items.each do |todo_item| %>
    <tr id="<%= dom_id(todo_item) %>">
        <td><%= todo_item.content %></td>
        <td><%= link_to "Edit", edit_todo_list_todo_item_path(todo_item) %>
        <%= link_to "Delete", todo_list_todo_item_path(todo_item),  method: :delete, data: { confirm: "Are you sure?"} %></td>
    </tr>
    <% end %>
</table>

<p>
    <%= link_to "New Todo Item", new_todo_list_todo_item_path %>
</p>