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 Build a Todo List Application with Rails 4 Build a Todo List Application with Rails 4 Adding Todo Items

Getting Syntax Error - Failure/Error: click_link "New Todo Item"

I've reviewed the code, rewatched the video, looked through the forums and googled the issue and I can't figure out what's going on. Here's the error:

Adding todo items is successful with valid content (FAILED - 1)

Failures:

1) Adding todo items is successful with valid content Failure/Error: click_link "New Todo Item" SyntaxError: /Users/tmckay/sites/treehouse/app/views/todo_items/new.html.erb:6: syntax error, unexpected keyword_end '.freeze;@output_buffer.append=( end );@output_buffer.to_s ^ /Users/tmckay/sites/treehouse/app/views/todo_items/new.html.erb:7: syntax error, unexpected keyword_ensure, expecting ')' /Users/tmckay/sites/treehouse/app/views/todo_items/new.html.erb:9: syntax error, unexpected keyword_end, expecting ')' # ./spec/features/todo_items/create_spec.rb:15:in `block (2 levels) in <top (required)>'

Can someone help?

5 Answers

Hmm ...

My code is further down the course than this so it is split out into a _partial at this point. However, my form_for looks like:

<%= form_for [@todo_list, @todo_item] do |form| %>

I'm not sure if the plurals in your code might cause the problems. Give that a go to see, else let's have a look at your test code. Mine looks like:

    it "is successful with valid content" do
        visit_todo_list(todo_list)
        click_link "New Todo Item"
        fill_in "Content", with: "Milk"
        click_button "Save"
        expect(page).to have_content("Added todo list item")
        within("td.todo_items") do
            expect(page).to have_content("Milk")
        end

Have you been using Github to remotely store your code?

Steve.

Hi,

Can you post your code in new.html.erb please? There seems to be a problem in there.

Thanks,

Steve.

Sure thing

<%= form_for [@todo_lists, @todo_items] do |form| %>
    <%= form.label :content %>
    <%= form.text_field :content %>

    <%= form.submit "Save" %>
<% end %>

While I'm 90% certain that I tried it with and without the plural form, it seems to be working now with the singular form. So confusing but I guess I didn't.

Thanks Steve

Cool - glad you got it fixed. :-)

Vinny Harris-Riviello
Vinny Harris-Riviello
11,898 Points

Just look at how you have them in your todo_items_controller.rb on your def new: there you defined your instace variables that is the way you want to call them on your html. Hope that clarifies why they should be in singular.