Ruby On The Beach: Week 3

January 25th, 2015 - Ubud, Bali

Another week of Ruby On The Beach has flown by! This week was particularly exciting, as we dove into the concept of Rails, a framework that enables the creation of powerful applications written in Ruby. Packages like Rails are an amazing reminder that software developers today are standing on the shoulders of giants, having been equipped with wonderful automation and behind the scenes processing power. It was incredibly empowering to see how quickly and easily we could build apps that just a decade ago would have taken exponentially longer.

It was another challenging week of absorbing programming concepts and beginning to put some of our knowledge to work by building real apps, but all of our work definitely began to pay off when we were able to interact with our code in the browser for the first time!

Screen Shot 2015-01-25 at 3.58.28 PM

One of the coolest aspects about reaching this milestone in the course is we were now able to tackle larger projects within small groups. This environment led to a lot of knowledge sharing, and I enjoyed picking up coding techniques and product management strategies from my peers within the cohort. Programming is hardly ever an individual undertaking, so it was a great experience to understand how folks with different backgrounds, skills, and mindsets approach solving the same problems.

Fabian, Luca, and myself designing a database schema (with instructor Brett observing)

The undertaking of a technology bootcamp entails a large portion of my week is spent in front of a screen, so having the accountability of RescueTime running in the background on my computer definitely helped keep me on track during those moments when focus started to fade. Although I bested my productivity score from the previous week, there's definitely still room for improvement. Screen Shot 2015-01-25 at 10.31.42 AM

As for my daily habit regimen, I started off strong this week before failing to check-in to all my habits on Friday and Saturday, as I definitely hit a wall and took some time to re-group before the beginning of another long week of learning. Screen Shot 2015-01-25 at 3.54.09 PM

The workout category is undoubtedly boosted by our yoga sessions three times a week, which I'm incredibly grateful to have incorporated into the curriculum. It's a testament to Ruby On The Beach's no burnout philosophy that we are encouraged to start our days establishing the mind-body connection and enjoying a much needed anxiety release. Screen Shot 2015-01-25 at 3.49.57 PM

Scaffolding in Rails

Our curriculum covered a plethora of rails concepts this week, including many I don't yet understand well enough to explain in a blog post. But there's one aspect that easily highlights the incredible powers of this framework: scaffolding. Pared down to it's most basic form, scaffolding enables the creation of a simple interactive website in just a couple of lines of code. Let's dive into this topic by building a semi-functional twitter clone.

Once the Ruby On Rails development environment is set up on your machine (which is no simple undertaking), to make a new application all you have to do is open the terminal and type:

rails new Twitter

Instantly, Rails goes berserk and configures a pre-ordained structure, then implements "gems" which enable the access of helpful third-party code blocks. Look at all those "automagically" generated folders and files!

Screen Shot 2015-01-25 at 4.34.57 PM

But at this point, our application doesn't actually do anything. We can quickly rectify that by running a devilishly simple command:

rails generate scaffold tweet username:string tweet:string

Let's break this down into bite-sized pieces:

  • Rails flags the terminal that what follows is a command in rails
  • Generate means we're about to create something!
  • Scaffold is what we're creating. Scaffolding is an easy way to build and interact with a simple application in the browser. It supports the creation, reading, updating, and deletion of objects - in this case, "tweets."
  • Author:string is an argument that means each instance of tweet should have a username that is a combination of numbers and letters.
  • Tweet:string means each instance of tweet should have some content as well.

Rails quickly interprets this and builds a whole set of files which serves as our basic scaffolding. If we now set up our database using rake db:migrate and fire up a local server by typing  rails server , then navigate to localhost:3000/tweets on a web browser, we can see the following:

Screen Shot 2015-01-25 at 4.40.04 PM

Incredibly, scaffolding creates bare bones HTML forms for all of the different pages you can now access. Without writing one more additional line of code, we can click on "New Tweet" to build an entire database of tweets. We even have the power to view, edit, and delete them.

Screen Shot 2015-01-25 at 4.55.53 PM

Now this might not seem miraculous to you, but the amount of work that Rails is doing on the back-end to enable this is relatively mind-boggling. Additionally, this is just one example of the power this framework enables developers with. I'm excited to see what next week's deeper dive into Rails has in store.