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

I am in great need of help, please! After cleaning up my code I have 7 errors. Can you tell me why? Thank you!

Below are three of the seven errors that show up. After making the change to the code to clean it up these showed up. There are three 'click link "New Todo Item"' failures and three and three 'click link "Edit"' failures. The last one is lookining for content. Thanks for your help.

Failures:

1) Adding todo items is successful with valid content Failure/Error: click_link "New Todo Item" SyntaxError: /home/bob/Source/projects/odot/app/views/todo_items/form.html.erb:17: syntax error, unexpected keyword_ensure, expecting $end # <internal:prelude>:10:in synchronize' # ./app/views/todo_items/new.html.erb:3:inblock in _app_views_todo_items_new_html_erb3317331261669237540_40491760' # ./app/views/todo_items/new.html.erb:2:in `_app_views_todo_items_new_html_erb_3317331261669237540_40491760' # ./spec/features/todo_items/create_spec.rb:15:in `block (2 levels) in <top (required)>'

4) Editing todo items is successful with valid content Failure/Error: click_link "Edit" SyntaxError: /home/bob/Source/projects/odot/app/views/todo_items/form.html.erb:17: syntax error, unexpected keyword_ensure, expecting $end # <internal:prelude>:10:in synchronize' # ./app/views/todo_items/edit.html.erb:3:inblock in _app_views_todo_items_edit_html_erb1825205256225485731_47154900' # ./app/views/todo_items/edit.html.erb:2:in `_app_views_todo_items_edit_html_erb_1825205256225485731_47154900' # ./spec/features/todo_items/edit_spec.rb:17:in block (3 levels) in <top (required)>' # ./spec/features/todo_items/edit_spec.rb:16:inblock (2 levels) in <top (required)>'

7) Viewing todo items displays item content when a todo list has items Failure/Error: expect(page).to have_content("Milk") expected to find text "Milk" in "Edit Edit" # ./spec/features/todo_items/index_spec.rb:35:in block (3 levels) in <top (required)>' # ./spec/features/todo_items/index_spec.rb:34:inblock (2 levels) in <top (required)>'

3 Answers

Rachel Bird
Rachel Bird
11,968 Points

Could I please still see the views new.html.erb and edit.html.erb?

Rachel,

Thanks for getting back with me. I just looked at the versions of the requested views and parts of them dropped out when I pasted them in. I believe that they should be complete now. I aplogize for not noticing that when I pasted them in.

Thank you again, and Merry Christmas!

Bob

edit_html.erb

<h1><%= @todo_list.title %> - Editing Todo List Item</h1> <%= form_for [@todo_list, @todo_item] do |form| %> <%= render partial: form %> <% end %>

new.html.erb

<h1><%= @todo_list.title %> - Add Todo List Item</h1> <%= form_for [@todo_list, @todo_item] do |form| %> <%= render partial: form %> <% end %>

Rachel,

The erroir that was occuring with my app concerning the link issue is resolved. You were on the right track but I didn't give you all the information that you needed. On the '_form.html.erb' page I had inadvertently copied the <%end%> onto the form as well. That was where the error was coming from.

I really appreciate your help. I still need to figure out why I was getting a couole of other errors and I might need your help with them. I hope you had a great Christmas!

Thanks again!

Bob

Rachel Bird
Rachel Bird
11,968 Points

Can you paste in the code you're getting the errors on? Like the views for new and edit for todo_items views and your index_spec file.

You have syntax errors, which aren't too tough to fix. The first two are saying you're missing a couple ends.

Rachel,

Thank you very much for taking a look at my code. It is my suspicion that the render partial: form might be the problem. I have included the code here as well. Thanks again!

Bob

edit_html.erb

<h1><%= @todo_list.title %> - Editing Todo List Item</h1> <%= form_for [@todo_list, @todo_item] do |form| %> <%= render partial: form %> <% end %>

new.html.erb

<h1><%= @todo_list.title %> - Add Todo List Item</h1> <%= form_for [@todo_list, @todo_item] do |form| %> <%= render partial: form %> <% end %>

_form.html.erb

<div id="error_explanation"> <h2><%= pluralize(@todo_item.errors.count, "error") %> prohibited this todo_item from being saved:</h2>

<ul>
<% @todo_item.errors.full_messages.each do |message| %>
  <li><%= message %></li>
<% end %>
</ul>

</div> <% end %>

<%= form.label :content %> <%= form.text_field :content %>

<%= form.submit "Save" %>

index_spec.rb

require 'spec_helper'

describe "Viewing todo items" do let!(:todo_list) { TodoList.create(title: "Grocery list", description: "Groceries") }

def visit_todo_list(list)
    visit "/todo_lists"

    within "#todo_list_#{list.id}" do
        click_link "List Items"
    end
end

it "displays the title of the todo list" do
    visit_todo_list(todo_list)
    within("h1") do
        expect(page).to have_content(todo_list.title)
    end
end

it "displays no items when the todo list is empty" do
    visit_todo_list(todo_list)
    expect(page.all("ul.todo_items li").size).to eq(0)
end

it "displays item content when a todo list has items" do
    todo_list.todo_items.create(content: "Milk")
    todo_list.todo_items.create(content: "Eggs")

    visit_todo_list(todo_list)

    expect(page.all("ul.todo_items li").size).to eq(2)

    within "ul.todo_items" do
        expect(page).to have_content("Milk")
        expect(page).to have_content("Eggs")
    end
end

end

Rachel Bird
Rachel Bird
11,968 Points

Hi Bob.

Rats. Still didn't work.

Rachel,

Is it possible that there is a short circuit between the form and the pages trying to send to it? I know that the error shows that it is missing an 'end' but In looking at the errors and comparing the lines of code with the error I am seeing that there is a disconnect there. Could it just be a difference in syntax between the different pages and there reference to the form page?

Please forgive me, I am grasping at straws here. I included the error text to see what you think. --- I really appreciate your help!

Bob

1) Editing todo items is unsuccessful with not enough content Failure/Error: click_link "Edit" SyntaxError: /home/bob/Source/projects/odot/app/views/todo_items/form.html.erb:17: syntax error, unexpected keyword_ensure, expecting $end # <internal:prelude>:10:in synchronize' # ./app/views/todo_items/edit.html.erb:3:inblock in _app_views_todo_items_edit_html_erb2499509007648331770_46731680' # ./app/views/todo_items/edit.html.erb:2:in `_app_views_todo_items_edit_html_erb_2499509007648331770_46731680' # ./spec/features/todo_items/edit_spec.rb:42:in block (3 levels) in <top (required)>' # ./spec/features/todo_items/edit_spec.rb:41:inblock (2 levels) in <top (required)>'