Class is in Session…

Joshua Singleton
3 min readNov 8, 2020

--

So you have a great web application. Users are able to go to your website and truly enjoy the value of your website. But do you really know your users? Do your users know that you know who they are? It’s time to get personal.

It is second nature for web application to save information from their users and create more value from that information. One of the be ways to do that is through creating a log in or sign up page that takes in the user’s information. I am going to show you how to create a personal experience for those visiting your website and bring more value to your web application.

I am going to be using terminology of Ruby on Rails application so the assumption is that you are creating your app with Ruby on Rails platform.

I will create a session for my web application, JCourts so that my user will have a personal experience. JCourts is a project Jeff Bollings and I worked on for our Rails on Ruby learning. It currently does not have authentication, a way for our website to know who is viewing our website. So we are going to apply it to our application together.

J Courts without Login and Personal User experience

First thing is set your routes for your signup and login pages. We will do these with restful routes. We will create a Welcome controller.

Creating a controller to welcome users

Create restful routes in for your Welcome controller to signup and login users.

adding resources to Welcome controller in the routes file in Config folder

Create a new method and create method in the Welcome controller. Once this is done create a new.html.erb template in your welcome/view folder. In this html file I will create my form for Sign up.

Creating Form in Ruby on Rails

That creates this on my webpage…

Web Page view of the form

Now it is time to create session controller. Session is going to put a restriction to different pages on the website unless user is signed up or logs in.

Create a Controller for Session

Create routes for your session. This will include a get request for the login and a post request.

Creating routes in the config folder

In your session controller make sure you have the following code:

Session Controller

This is so your user id becomes the session’s id and therefore creates a personal experience.

Once you have that just make sure there is a link on the homepage to log out and that will destroy the session

There you go! You have created a personal experience for your users.

HAPPY CODING!!!

--

--

Joshua Singleton
Joshua Singleton

Written by Joshua Singleton

Student of Code in the hopes of creating a new social network to enhance the community!

No responses yet