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
mnwogdbvte
16,349 PointsAdding Todo Items
When I run the final test after putting into the strong parameters code I get a failure and the reason is
1) Adding todo items is successful with valid content
Failure/Error: expect(page).to have_content("Milk")
expected to find text "Milk" in ""
After looking into the problem more, if I run the server and add a todo item it will successfully accept and save and redirect to the todo_list_todo_items_path, but the todo_item content is blank. After looking through the server log I see a goofy looking result that the server doesn't know the values when inserting into "todo_items":
SQL (14.8ms) INSERT INTO "todo_items" ("created_at", "todo_list_id", "updated_at") VALUES (?, ?, ?) [["created_at", Tue, 24 Dec 2013 21:14:00 UTC +00:00], ["todo_list_id", 2], ["updated_at", Tue, 24 Dec 2013 21:14:00 UTC +00:00]]
Anyone else having this issue or know how to fix it?
Thanks!
5 Answers
Jason Seifer
Treehouse Guest TeacherHey Devan Beitel over here:
https://github.com/DevanB/odot/blob/master/app/controllers/todo_items_controller.rb#L25
Change it to this:
params.require(:todo_item).permit(:content)
And that should do it.
Jason Seifer
Treehouse Guest TeacherAlso, on line 13 it should be todo_item_params instead of params[:todo_item_params].
Jason Seifer
Treehouse Guest TeacherHey Devan Beitel can you give us a link to your code?
mnwogdbvte
16,349 PointsHoly cow. Old thread hah. I was thinking about taking another look at this last weekend, but got distracted by some other apps.
You can find the repo here: https://github.com/DevanB/odot. There was a lot of stuff I wasn't too sure about, that hadn't been pushed yet, so I just pushed it. It's probably all old and smelly bad stuff now.
mnwogdbvte
16,349 PointsInteresting, wonder how I got that syntax. Did it change since you first posted the course?
I'm definitely going to jump back into it now. I'll have to start from the beginning just for good measure.
Thanks for the help!