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 Editing Todo Lists

Hiroshi Kadokura
Hiroshi Kadokura
8,035 Points

I dont know how he did that...

In the video around 11:10 ... what and how did he do that?? I dont think he copied something and pasted it on line 31.

I need your help!!

3 Answers

Yes, unfortunately, this happens quite a lot in this course. The teacher pastes code into the app without providing the code below the video for us to do the same.

In this instance, he does go through the tests that he copied, and they are fairly straightforward.

Feel free to copy the code from my Github repo, here.

Steve.

Hiroshi Kadokura
Hiroshi Kadokura
8,035 Points

Thank you so much!! Yes, the code did work !!

John Simoneau
PLUS
John Simoneau
Courses Plus Student 8,105 Points

That was an interesting approach...LOL. I don't think he was considering those of us following along typing the code with the video. I know you could download the course files but I was determined to do it the uselessly longer route by skipping around in the video on those spots and typing each line I could find as well as using my own logic based off the create_spec file we had already created. Anyways, the GitHub repo link works above as-does downloading the course files. But if anyone is looking to be lazier the following a couple links here is what I came up with and works. I'm 99% sure it's what the instructor has as well.

require 'spec_helper'

describe "Editing todo lists" do
    let!(:todo_list) { TodoList.create(title: "Groceries", description: "Grocery list.") }
    def update_todo_list(options={})
        options[:title] ||= "My todo list"
        options[:description] ||= "This is my todo list."
        todo_list = options[:todo_list]

        visit "/todo_lists"
        within "#todo_list_#{todo_list.id}" do
            click_link "Edit"
        end

        fill_in "Title", with: options[:title]
        fill_in "Description", with: options[:description]
        click_button "Update Todo list"
    end

    it "updates a todo list successfully with correct information" do
        update_todo_list todo_list: todo_list, 
                         title: "New title", 
                         description: "New description"

        todo_list.reload

        expect(page).to have_content("Todo list was successfully updated.")
        expect(todo_list.title).to eq("New title")
        expect(todo_list.description).to eq("New description")
    end


    it "displays an error with no title" do
        update_todo_list todo_list: todo_list, title: ""
        title = todo_list.title
        todo_list.reload
        expect(todo_list.title).to eq(title)
        expect(page).to have_content("error")
    end

    it "displays an error too short of a title" do
        update_todo_list todo_list: todo_list, title: "hi"
        expect(page).to have_content("error")
    end

    it "displays an error with no description" do
        update_todo_list todo_list: todo_list, description: ""
        expect(page).to have_content("error")
    end

    it "displays an error too short of a description" do
        update_todo_list todo_list: todo_list, description: "hi"
        expect(page).to have_content("error")
    end

end
Jack McDowell
Jack McDowell
37,797 Points

Thanks to both of you. Seriously though, this course could have easily been broken up into 3 or 4 parts. There are moments like these when there wasn't even enough time to pause the video and write the code!

Hoppy Toad
Hoppy Toad
5,773 Points

Everyone who is annoyed by the lack of explanation of where that large block of code came from should click "give feedback" at the end of the video and give it a low rating. Be sure to explain why.

David Richied
David Richied
18,057 Points

I agree. The instructor may have just been given an almost impossible task and made the best of it with this course. I am considering taking his other eight-hour course called Build a Simple Ruby on Rails Application instead of this course and see if it's better paced. I suppose they thought the Rails Development track was long enough (53 hours) and just wanted to put in a shorter course.