Rails Portfolio Project
My rails portfolio project was the third end of module project completed for my Flatiron curriculum. I created an application using Rails 6, that allows a user to create and review a rental. Here are some tips I’ve gathered for successfully creating a working application:
- Debug with Pry: Pry’s tag line of “Get to the code” is the most succinct explanation of Pry. Pry is a REPL developer console with a plethora of features — my favorite being the ability to dig into methods and their return values. Using Pry is as simple as adding Pry into your gemfile, adding ‘require pry’ to the top of your file, and finally add ‘binding.pry’ inside the method you’d like to take a deeper look into. Using Pry saved me countless hours in resolving “NoMethodError: undefined method for nil:NilClass” problems.
- Devise: Devise is a useful gem that allows for flexible authentication. Devise is simple to use and consists of 10 modules that cover all aspects of user authentication, from sign-in to sign-up. Devise is also Omniauthable, which allows for sign-in from your favorite sites like GitHub, Gmail and Facebook. I applied Facebook with Omniauth as a third party authentication in my application.
- Triple check your schema: I began my project by writing out all of my migrations and from there moved onto my controllers and views. One of the first errors I ran into was stemming from how I was defining an attribute of my User model. Rather than using ‘username’ I was applying ‘name’. Although this error was simple to resolve, I could have save myself time by looking at my schema prior to sketching out my controllers and views.
- Spend time to plan out your project: One of the biggest challenges I tend to face in my projects is the desire to add everything and anything feature wise. Although I spent a few hours before any actual coding to map out what I wanted my application to look like I still managed to get bogged down within the first week of coding by trying to add in unnecessary features that did not relate to the provided specs. When you’re on a strict time schedule, going in circles over unneeded additions can be detrimental.
Overall I thoroughly enjoyed writing my first Rails application and found it to be exciting. Learning the basis of how Ruby, Sinatra and ActiveRecord works prior to jumping into Rails gave me a clear structure to follow and the ability to understand the documentation I poured over while writing my project. I look forward to many more days spent building creative and functional applications.