To practice RoR I'm working on a tutorial which has me build a todo list. Everything has been going swimmingly so far until the tutorial had me ensure that each todo list belongs to a user.
I've spent quite a few hours trying to fiddle with ways to ensure the app is recognizing that a user is signed in but I just can't seem to get it to work. The current state of my app is on my github at https://github.com/Baron-burton/odot >From the state of my todo list on my Git page I go to my todo list controller >spec to test if a todo list is assigned to a user, will that test pass? I do >this by changing: " let(:valid_session) { {} } before do sign_in(build_stubbed(:user)) end " to " let(:valid_session) { {} } let!(:user) { create(:user) } before do sign_in(user) end " To fix the sign in error this creates in rspec I then head to my app/controller/todo_lists_controller and ensure when a todo list is created it is assigned to a user. I do this by changing: " def create @todo_list = TodoList.new(todo_list_params) " to " def create @todo_list = current_user.todo_lists.new(todo_list_params) " This is where the problems start to arise. Instead of fixing the 1 error as it shows it does in the tutorial I end up breaking every test in my todo list controller spec folder under " describe "POST create" do " The error is: " TodoListsController POST create with valid params creates a new TodoList Failure/Error: post :create, {:todo_list => valid_attributes}, valid_session NoMethodError: undefined method `todo_lists' for :user:Symbol # ./app/controllers/todo_lists_controller.rb:28:in `create' # ./spec/controllers/todo_lists_controller_spec.rb:75:in `block (5 levels) in <top (required)>' # ./spec/controllers/todo_lists_controller_spec.rb:74:in `block (4 levels) in <top (required)>' " This is repeated 4 more times for each test within the POST create method. I would love for someone to take a look at my code if they have the time or offer any potential solution to my error. Happy New Year to everyone! - Brandon -- You received this message because you are subscribed to the Google Groups "North West Ruby User Group (NWRUG)" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send an email to [email protected]. Visit this group at https://groups.google.com/group/nwrug-members. For more options, visit https://groups.google.com/d/optout.
