It would seem like a natural progression to learn Ruby programming before learning Rails. However my journey into Rails didn't start with Ruby, I jumped into Rails straight away and here are some of the things in Ruby I wished I understood before I began learning Rails.

Distinction between Ruby / Rails

After generating a rails project I was greeted with tons of code that seemed overwhelming at first and a lot of things seemd to have worked very 'magically'. Alot of the reasons why it felt like magic was because

1. I didn't know which parts were Rails and which were Ruby

2. I didn't know the extent of Ruby's capability as a programming language

As a result I feel like it took me longer than needed to be truly productive with the Rails framework. Here are some example of things I saw in the generated Rails project or reading through online Ruby on Rails tutorials that perplexed me initially.

Everything is an Object

You here this repeated a lot when starting to learn Ruby or Rails. I never understood what it means and how it relates to me as someone learning programming. So to help my students in learning Ruby I created a quick video that will make it easy to understand what it means. Click on the image to watch the video.

Symbols were Confusing

I was aware of strings and integers as a common data structure in other programming languages however symbols were new to me and I always wondered why they existed. I thought this was also a part of Rails and never understood why we needed to have symbols. This is why I made the following video explaining Symbols to newcomers of the Ruby / Rails ecosystem

Classes vs Objects

When I started Rails I had been programming in C / C++ before and the concept of object oriented programming was quite new to me and I was still grasping the concept of classes and objects, what were the difference between them and I just ignored understanding any of this until I hit a road block. The road block was when I eventually had to define my own class and use them in my project.

Loops and Iterators

The .each method seemed too good to be true, in other languages generally you would have to deal with 'for' loops if you wanted to iterate through a list of things or out put a list of things in html partials. In ruby it was just .each in front of the thing you want to loop through. WOW! makes sense! But at first I thought it was a Rails specific thing and as a result it made me weary and nervous if I ever had to step outside of the comfort zone of Rails. If I had to go back I would take the time to learn how loops and Iterators worked in Ruby.

Debugging with p vs puts

When I was learning building apps with Rails I used to read a lot of documentation and tutorials online and puts was a very popular method for outputting values of variables or any kind of state in the app, however this sometimes lead to a lot of confusion. If I had taken the time I would have know that 'p' was the better method call to use if I wanted to preserve the data type.

Bang (!) and No Bang method calls

This one was another mystery, as I was working on my first rails project I would come across method calls that had ! in them and not know what they mean or how they differ from the standard version. I had to go look up examples on line and some of them made me even more confused. Here is a simple explanation of the difference

Wrap Up

These are just a list of the common things that come up when learning ruby on rails. There is a saying that says hindsight is 20 /20 looking back these are some of the things I wish I had learned about ruby before diving into building web applications with Ruby on Rails. I hope you find it useful. Stay tuned for more of these useful tips about Ruby. If you would like to learn ruby from scratch you can start from the beginning here.

If you like what you read here and want to support us you can check out our site Codemy.net we have content for Ruby / Rails / ReactJS and Elixir. You can support us by becoming a member for just $9 / month. You'll get access to all member's exclusive content.