Application monitoring that helps developers get it done.
Deploy apps to servers that you own and control.
Now that we have our base styles prepared and our authentication system in place, we can focus on allowing users to sign up for our application. To do this, we'll use the scaffold generators that Rails provides.
Let's jump into our application and examine the command we need to run. We will scaffold the user resource with an email address and a password. However, since the authentication generator has already created this model and migration, we need to skip the collision check. This ensures that if any files already exist, Rails will skip them instead of raising conflicts.
Running the command, we see that Rails:
Now, let's review our user controller. It follows the standard RESTful pattern, including:
We'll use this setup to allow users to sign up. The new action will render the signup form, which submits to create. Once a user successfully signs up, they will be redirected to the show page.
Since signup happens before authentication, we need to explicitly allow unauthenticated access for new and create. This mirrors what we did in the sessions controller for login functionality.
Before making further modifications, let's commit our changes.
Navigating to /users/new, we see the default signup form. The base styles are working well, but a few improvements are needed:
To streamline the user experience, we'll:
Jumping into the controller, we delete the index action and remove the corresponding view and route. Next, in our Tailwind CSS file, we define new form styles.
Now, form elements have better spacing. However, the input fields are not full-width. Investigating the issue, we see that styles were only applied to direct children of forms. To fix this, we extend styles to descendants instead of only direct children.
Now our form looks clean and structured.
At this point, the signup form functions correctly, but:
To fix this, we update the users controller:
def create
@user = User.new(user_params)
if @user.save
start_new_session_for @user
redirect_to @user, notice: "Welcome! You are now signed up."
else
render :new, status: :unprocessable_entity
end
end
Now, after signing up, users are:
Testing the changes, everything works seamlessly. The last step is to remove any remaining references to the index action and improve flash message styling, which we can refine later.
With signup fully implemented, let's commit our changes.
Now, we can move forward and focus on building the post submission feature for our Lorem News application.