diff options
author | Matthew Lemon <y@yulqen.org> | 2024-11-20 20:48:22 +0000 |
---|---|---|
committer | Matthew Lemon <y@yulqen.org> | 2024-11-20 20:48:22 +0000 |
commit | 6676d7cbd85a42de043b0ed1769e82a12a1cb035 (patch) | |
tree | 9825c056a4dc741f66dabc8505df0cc0f4e16ed0 /app/controllers | |
parent | 11ade983c06afc0a4cf8787e9c3ef413786be84b (diff) |
Adds a users controller to fix sign-up bug
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/users_controller.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb new file mode 100644 index 0000000..c49a295 --- /dev/null +++ b/app/controllers/users_controller.rb @@ -0,0 +1,22 @@ +class UsersController < ApplicationController + allow_unauthenticated_access only: %i[ new create ] + def new + @user = User.new + end + + def create + @user = User.create(user_params) + if @user.save + start_new_session_for @user + redirect_to root_path, notice: "Successfully signed up!" + else + render :new + end + end + + private + + def user_params + params.expect(user: [:first_name, :last_name, :email_address, :password, :password_confirmation]) + end +end |