Building a simple ridesharing website with Ruby on Rails

Earlier this year I completed a university course Programmatic Content Management. Part of the course was to build a website using a technology of your choice and implement at least CRUD features and  user log in & log out. Before taking the course, I had some experience from C++, HTML & CSS, but nothing really relevant to build a working web application. After doing to initial research, I decided to try Ruby on Rails. After learning the basics from Coursera, the framework seemed appropriate for the task at hand.

I didn’t have any groundbreaking problem to solve with my app, but then I came up with an idea: after using services such as Bla Bla Car and Prevoz, I wasn’t satisfied with current Finnish services. Therefore, I decided to create a simple website for this purpose:

  • Create rides with time, date, starting point and destination
  • Edit and delete the rides you created
  • Log in with username or social media account
  • Display some contact information to allow users to connect with ride offered.

After setting up an account for Heroku, local PostgreSQL instance and GitHub repository, I was ready to start.

The MVC architecture is behind rails and with scaffolding it is fast to set up a working prototype for ride creation. To create users, I used a gem called Devise. With Devise and following instructions, it was easy to set up the user model and create a relationship between users and rides. In addition, I enabled Bootstrap and simple_forms to enhance the visual side of the web site.

screen-shot-2016-12-06-at-11-46-37

I also allowed users to use Facebook and Google accounts to login to the website. With devise, it is easy to use other gems and set up authentication for multiple providers. With both Facebook and Google, the process it quite straightforward.

screen-shot-2016-12-06-at-11-44-05 screen-shot-2016-12-06-at-11-44-29 screen-shot-2016-12-06-at-11-44-55

After these steps, the database schema was on its final form. Rides_controller had its methods. With omniauth controller and registrations, everything was okay for users and logins.

To add some extra value, I used Google Directions API to check distance between the destination and starting point:

In the future, it would be interesting to utilise more this kind of data and offer directions, waypoints, travelling times and other beneficial information to users.

Lastly, I created a very simple visualisation with Highcharts and a useful gem. At the moment, a simple line chart is displayed to visualise distances between different locations.

screen-shot-2016-12-06-at-11-42-19

The whole source code is available at https://github.com/g00g0l/RideSharing  and the website is running at the moment on Heroku: https://falckk.herokuapp.com

Leave a Reply

Your email address will not be published. Required fields are marked *