Learn
Great! When you visit the URL /signup
, the browser makes a GET request for the URL. This request hits the Users controller’s new
action, which returns a view displaying the signup page.
Instructions
1.
Next, let’s take in data submitted through the signup form and save it to the database.
In the Users controller, add a private method user_params
private def user_params params.require(:user).permit(:first_name, :last_name, :email, :password) end
2.
Between the new
action and the private method, add the create action
def create @user = User.new(user_params) if @user.save session[:user_id] = @user.id redirect_to '/' else redirect_to '/signup' end end
3.
Visit http://localhost:8000/signup
and sign up as a new user.
Sign up to start coding
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.