Rails Console | Ruby on Rails Project

Alex Sanchez
3 min readFeb 7, 2021

My Ruby on Rails Portfolio project is my third project in the Flatiron School curriculum, so I’ve come to know more of what to expect when project building time comes around! A bit less anxiety and a bit more confidence this time around compared to the first two projects. Halfway done with Flatiron School, and I’m finally getting the hang of at least learning to code!

For my Rails project, I chose to create a content management system for coffee drinks, CoffeeMakr. Using the web app, employees/owners of a coffee shop could find something similar useful to create and keep track of any various drinks on their menu and any other user can go see how to make it or leave a review on it!

While my project build this go around was fairly straightforward, and I managed to hit all the requirements in half the allotted time (yay days off!) it was not without its snags here and there. One of the most useful little things that helped in a pinch was being able to utilize the Rails console (honorable mentions to Byebug and Pry as well!).

Typing ‘ rails c ‘ into your terminal allows you the freedom to play around with your database and create, find, and call methods on your objects! It’s like a back door into your project from the command-line without having to use the browser. Especially useful when you want to test if all of your models are working properly before spending a lot of time on your views, etc.

Note: utilize ‘ rails c -s ‘ to make your rails console act as a sandbox environment and not save everything to your database permanently!

Similar concept as creating a rake helper for console and calling ‘rake console’ when in our Sinatra module, but I have found myself using the Rails console much more (likely due to laziness and not taking the time to make rake console work!).

A cool trick (though maybe not the best method) in the Rails Console when working on my first Rails project was utilizing the console to try out route helpers! To do so, you call the methods on the implicit ‘app’ object:

Of course http://localhost:3000/rails/info/routes can come even more in handy to see and search for existing routes to which you have access! I find the browser version a bit more easy to navigate than just trying out route helpers or utilizing the ‘ rails routes ‘ console command, but try them all and see what works best for you!!

I learned a lot in our Rails module, and the project build always fleshes out the gaps in my knowledge, ultimately solidifying what I have to learn multiple times more. At the end of the day, a lot of the Rails “auto-magic” is mind-blowing! Sometimes, the even the small things — like rails c — make a big impact, too.

--

--