However, the index error only shows up when I refresh the browser because I’m also getting an ActionController::InvalidAuthenticityToken in SignupsController#create error when I click on the submit button.
Here’s what I see in the console: Started POST "/signups" for xx.xx.xxx.xx at 2020-06-05 17:58:40 +0000 Processing by SignupsController#create as HTML Parameters: {"utf8"=>"✓", "authenticity_token"=>"ISh57AUCeODOur3cP1nkurexm13tyQhVI1d1UrgfQ2o=", "signup"=>{"email"=>"test@email.com"}, "commit"=>"Join"} Can't verify CSRF token authenticity Completed 422 Unprocessable Entity in 1ms
So this doesn’t solve the underlying problem, but will allow you to get beyond this issue for further practice —
In your signups controller, add this line above any of your actions
skip_before_action :verify_authenticity_token
This basically tells the signup controller to not care about the authenticity token. You should not do this in a production app, but inside codecademy for practice/learning, it’s probably fine.
@evanfreeze Thanks for the solution, it also helped me out. I’m also curious to know what was causing an invalid authenticity token? Can anyone explain?
The issue persists, and this solution still works.
I would like to add that the situation is not unique to this project. The following project, Threadly, issues the same error when it comes to submitting comments. I added the skip_before_action and it works just fine.