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 trialJohn Salzarulo
6,596 PointsMy whole database showing below my <UL>?
What is going on?
Made it this far everything is working. However, when I view items it shows me a strange database like listing of all the items.
Here is an example:
* Pencils
* Paper
* Books
* Homework
[#<TodoItem id: 23, todo_list_id: 17, content: "Pencils", created_at: "2014-09-26 03:30:49", updated_at: "2014-09-26 03:30:49">, #<TodoItem id: 24, todo_list_id: 17, content: "Paper", created_at: "2014-09-26 03:30:52", updated_at: "2014-09-26 03:30:52">, #<TodoItem id: 25, todo_list_id: 17, content: "Books", created_at: "2014-09-26 03:30:56", updated_at: "2014-09-26 03:30:56">, #<TodoItem id: 26, todo_list_id: 17, content: "Homework", created_at: "2014-09-26 03:31:10", updated_at: "2014-09-26 03:31:10">]
To be clear, this is what shows on my localhost in my browser whrn visiting the "List Items" link from the index. Everytime I add new items they populate in this strange soup below.
Here is my view code for this index:
<h1> <%= @todo_list.title %> </h1>
<ul class="todo_items">
<%= @todo_list.todo_items.each do |todo_item| %>
<li><%= todo_item.content %></li>
<% end %>
</ul>
<p>
<%= link_to "New Todo Item", new_todo_list_todo_item_path %>
</p>
There is nothing in this index view that would push this through! So annoyed.
What I have done:
- Double checked my views (Code above)
Link to full code:
What do you guys think? Please help. I've been trying to fix this for hours.
1 Answer
Maciej Czuchnowski
36,441 PointsThis line:
<%= @todo_list.todo_items.each do |todo_item| %>
You have to remove the =
and it will work. The =
symbol prints things on the screen, so you remove it in parts that you only want evaluated and not printed.
John Salzarulo
6,596 PointsJohn Salzarulo
6,596 PointsThank you thank you.