What I learned building my first rails application.

Hello, again! As per usual, it has been a while since I have posted... but I am back with some exciting news. I've finally finished my rails application!! 😃🎉 I wanted to write about my journey and what I learned, so this blog post will be about just that! Hope you've all been well and thanks for following my journey!

How I did it

A little less than 2 months ago, I started going through Michael Hartl's Rails Tutorial to learn Ruby on Rails. My evening's after work were spent reading through the chapters and building the sample application along with the book. I went through about half of the book before I realized this method of learning probably wasn't best for me. I felt like the information wasn't sticking as much, because I was building something straight out of a tutorial rather than having to struggle to find how to do something in the way I might if I were to build something from scratch (with no code to copy from a book/tutorial). So, I started over. I thought about an application that I wanted to make (which was surprisingly hard to do for me). I re-read the sections of the tutorial which covered the fundamentals (how to generate MVCs, migrations, etc). And I googled the rest that I didn't know how to do.

What I built

Inspired by some friends, I built a rails application called TIL notes, which stands for Today I Learned. The application can be viewed here: https://tilnotes.herokuapp.com/.

Functionality

As a user of the rails application, one has the following capabilities:

  • Create, Edit, and Delete a cheatsheets
  • Make your cheatsheet public or private
  • Search cheatsheets by tag (only public cheatsheets are searchable)
  • Favorite/unfavorite a cheatsheet
  • Access a list of all your favorited cheatsheet
  • Edit profile/settings, reset password
  • View other users' profiles
  • Follow/unfollow other users

Rails Application Preview

What I learned

This being my first real rails application, I learned a ton!!! I'll attempt to list what I learned below, but I may be forgetting to include a thing or two...

Rails Things

  • How to generate a model and controller
  • How to generate a database migration
  • How to reset, migrate, and seed the database to show fake data
  • How to create templates using embedded Ruby
  • How to create partials to use in views
  • How to use persistent cookies to maintain state and remember users
  • How to generate Action Mailer actions and views to send email
  • How to use a generated token to create a unique URL to activate users
  • How to identify users for password resets (hashed reset digest to identify valid reset requests)
  • How to create an association between models (has_many and belongs_to methods in the Models)
  • How to query for Active Record selections
  • How to use Ajax to asynchronously send requests to the server without leaving the page (used in the following users and favoriting cheatsheet actions)

Other Things

  • How to practice Test-Driven Development / Behavior Driven Development
  • Write tests first to help predict course of development and document what is planned to be achieved in terms of test coverage.
  • Run tests that fail.
  • Write code to get the tests to pass.
  • How to write requests specs with Rspec and the difference between request specs and controller specs
  • Request specs include full routing and are designed to drive behavior
  • using Git to organize the project, creating new branches for different features, creating PRs (thanks to my friends who reviewed them!!), etc
  • How to use FactoryBot to set up objects to test with
  • How to use SimpleCov to track files and their coverage

What's next?

As much as I would like to continue working on this rails application, I know that my time is best spent moving on to the next thing. What that is, I'm not exactly sure yet. I may continue to go through the rest of The Odin Project or I may sit down and study some Object Oriented Design Principles in Ruby... I suppose I will keep you posted once I figure it out.

Thanks for reading! 💝