Instructions step 13:
"In the Signups controller, make an action named create. Use signup_params to safely collect data from the form and update the database. After saving to the database, redirect to thanks_url. "
My issue:
In the app, everything in the form is working, except the redirect. After I enter en email, it saves to the db but doesn’t redirect to thanks_url. There is a thanks.erb.html page in the views that is provided with pre written code, I believe it is the one I’m supposed to be redirecting to. Here’s my code in the signups_controller:
class SignupsController < ApplicationController
def new
@signup = Signup.new
end
def create
@signup = Signup.new(signup_params)
@signup.save
redirect_to 'thanks_url'
end
private
def signup_params
params.require(:signup).permit(:email)
end
end
Or, maybe there is an error in my routes.rb file. Here is my code:
Rails.application.routes.draw do
root 'signups#new'
get '/thanks' => 'thanks#Pages'
resources :signups
end
And here is the code that was provided in the views for the thanks.erb.html page:
<div class="header">
<div class="container">
<h1>Thanks.</h1>
<p>We'll keep you posted.</p>
</div>
</div>