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 Cleaning Up Our View

Rachel Addleman
Rachel Addleman
10,162 Points

Having issues with removing mark completed section.

EDIT: Found my answer! My code keeps failing the tests even after I've done what was shown in the video. Here is my code

<td><%= todo_item.content %></td>
        <td>
            <%= if todo_item.completed_at.blank? %>
            <%= link_to "Mark Complete", complete_todo_list_todo_item_path(todo_item), method: :patch %>;
            <%= end %>
            <%= 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>

And here is the error message I keep getting back in terminal.

Failure/Error: visit_todo_list todo_list ActionView::Template::Error: /home/treehouse/projects/odot/app/views/todo_items/index.html.erb:9: syntax error, unexpected ')', expecting keyword_then or ';' or '\n' ...todo_item.completed_at.blank? );@output_buffer.safe_append=' ... ^ /home/treehouse/projects/odot/app/views/todo_items/index.html.erb:11: syntax error, unexpected keyword_end ';@output_buffer.append=( end );@output_buffer.safe_append=' ^ /home/treehouse/projects/odot/app/views/todo_items/index.html.erb:15: syntax error, unexpected keyword_end, expecting ')' '; end ^ /home/treehouse/projects/odot/app/views/todo_items/index.html.erb:23: syntax error, unexpected keyword_ensure, expecting ')' /home/treehouse/projects/odot/app/views/todo_items/index.html.erb:25: syntax error, unexpected keyword_end, expecting ')' # ./spec/support/todo_list_helpers.rb:5:in block in visit_todo_list' # ./spec/support/todo_list_helpers.rb:4:invisit_todo_list' # ./spec/features/todo_items/complete_spec.rb:9:in `block (2 levels) in <top (required)>'

If someone could give me some advice I would really appreciate. If more information is needed please let me know

~ Rachel

5 Answers

Michelle Cannito
Michelle Cannito
8,992 Points

Go back to your complete_spec.rb file.

Look where you added context "with completed items" do

That is a block. The two "it" tests need to be within that block. That is probably where your error is.

The first "it" test has 2 "end" statements, one for the "while" and one for the "it".

The second "it" tests winds up with 4 "end" statements: one for the "while", one for the "it", one for the "context", and the final one for the "describe".

Michelle Cannito
Michelle Cannito
8,992 Points

Oh wait, I had a similar error and it drove me nuts. Since the text line with method: :patch was so long, I had hit enter to put it on two lines

Expand the right side of your text editor till it all fits on one line. Then save it in that position.

It doesn't seem logical, but that is what finally worked for me.

Rachel Addleman
Rachel Addleman
10,162 Points

Michelle Cannito, Thanks for your responses. Neither of your suggestions seemed to work though.

Here is my code from the complete_spec.rb that was changed in this lesson.

context "with completed items" do
        let!(:completed_todo_item) {todo_list.todo_items.create(content: "Eggs", completed_at: 5.minutes.ago)}

        it "shows completed items as complete" do
            visit_todo_list todo_list
            within dom_id_for(completed_todo_item) do
                expect(page).to have_content(completed_todo_item.completed_at)
            end
        end

        it "does not give the option to mark complete" do
            visit_todo_list todo_list
            within dom_id_for(completed_todo_item) do
                expect(page).to_not have_content("Mark Complete")
            end
        end
    end
end

If anyone else has other suggestions I'd be happy to try them.

~ Rachel

Rachel Addleman
Rachel Addleman
10,162 Points

After looking at my code again I realized I had 2 equals signs where they shouldn't have been.

My line of code was

<%= if todo_item.completed_at.blank? %>

instead of

<% if todo_item.completed_at.blank? %>

I did the same thing with the end a few lines later. Removing the = made the tests work again. ~ Rachel

Michelle Cannito
Michelle Cannito
8,992 Points

So glad you got it working! Now you have your sanity back until the next bug hits.

By the way, in that course, I found myself just copying without really understanding the names or language.

Here's a suggestion: Go to the library and do the other Rails course that was removed from the track. Even though it uses older versions, it is 100 times better. The instructors explain every single step and every new name, syntax and method. It all makes sense!

The other course is named Build a Simple Ruby on Rails Application. The app is called Treebook, and, mimicking a barebones shell of facebook, it allows you to display a list of statuses and create, update, and delete statuses. It introduces Bootstrap, the simple_form gem, CoffeeScript and other really cool things.