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

Brandon Burton
Brandon Burton
9,688 Points

Switching to current_user.todo_lists bugs more of my code.

This is part of the Scoping Todo Lists video from the User Authentication with Rails course.

When I switch the code

def create
    @todo_list = TodoList.new(todo_list_params)

to

def create
    @todo_list = current_user.todo_lists.new(todo_list_params)

I get the error:

TodoListsController POST create with valid params creates a todo list for the current user
     Failure/Error: post :create, {:todo_list => valid_attributes},  valid_session
     NoMethodError:
       undefined method `todo_lists' for :user:Symbol

This switch in my code bugs every other test in my todo_lists_controller_spec file. I go from having 1 error to 6.

I have spent quite a bit of time on this trying to get the app to recognize that I'm logged in but I can't seem to fix it. Has anyone else had this trouble then completed it or can tell me where I may be going wrong?

Thank you.