When I first started learning ruby on rails, I had no idea they were two separate things. I went to a workshop, built something cool, and continued looking at tutorials from there. I guess I knew some things were ruby tutorials and some were ruby on rails buck didn't fully comprehend the difference. It wasn't until one day, when someone asked me about my learning path, the I realized I had some research to do.
So I went home, and looked and everything I found talked about ruby on rails or just ruby. It was pretty difficult to figure out what was pure ruby versus what rails brought to the table. During the presentation, I compared ruby and rails to the Settlers of Catan game and expansion packs available (which is what you'll see in the slides which are attached). For those of you who are fans of the real housewives of new jersey, you can also think of it like the original cast/season versus newer seasons.
So, what's what....
Well, to start, ruby is the base. It is a programming language like python or php. And you can use different stuff on top of ruby. You can use rails, but you can also build an apication with ruby and node or ruby and backbone, etc.
Rails is built on ruby. It is an open source web application framework. Rails are like the other seasons of housewives... Where new characters are introduced and original character are enhanced by the new characters. Take Teresa and melissa for example. Teresa has been there from the beginning but when melissa joined the cast, it allowed for more flexibility, more storylines and a whole new set of drama. If you don't watch housewives, but play catan, Rails is like an expansion pack. Just like in all of these versions of settlers, most of them use all or some of the pieces of the original settlers to build new versions that are more flexible, give you more game options, etc.
So here are some of the basics... in settlers, the original, you’ve got some basics like the resource map, the resource cards, dice, houses, roads, settlements, etc. Housewives is the same way... Think of the original cast with Teresa, Caroline, and Jacqueline set in Jersey. In ruby, you have the base of an object-oriented programming language. It also uses gems and something called IRB.
To go a little more into each of those things, IRB is interative riby. It’s a way to try things out using the command line. you can get to irb by typing irb into your command line. The command line will change a bit. To see how this works try typing
enter. You'll see IRB does the math for you. Now do
enterand you'll get nine. You just set the variable Teresa to the number three and then used it to do some math. There are lots of different things you can do and test in IRB. I’m still getting the hang of how to use it really effectively while coding.
The other thing I mentioned were gems. Gems are a packaged library or application. They are code grouped together to allow easy integration of certain functionality. There are lots of gems. And rails is a gem. Some gems I've used include Ransack which is an easy way to integrate search into a site and bootstrap which is a design gem that adds css and some prettiness.
Okay, so then what does rails add… Rails is like the pieces that come in the expansion pack or in new housewives seasons. So, for example, in seafarers, you get additional water pieces, ships, etc. that allow you to have different boards and built off of the original settlers. In housewives, we got the addition of joe, melissa, and kathy.
Rails follows the rules of MVC and DRY. It uses the Rails console, can query a database, and has commands like rails generate or scaffold which give you out of the box builds.
Okay, so there’s a lot there. To start, MVC is model, view, controller. This is a rails pattern.The model handles the logic. The controller handles the actions of requests and responses, clicking to navigate, form submissions, etc. and the v is the view or what you actually see. In ruby there’s no MVC pattern. This is a little confusing but Models and controller are just classes that make up the state and behavior but with the addition of view, it creates a pattern that rails follows.
DRY stands for don’t repeat yourself. Basically, that means if an element is being used over and over again, rails lets you group the code into something (like a module or helper) and continue to use it by including that item instead of rebuilding the element each time.
The other main thing is scaffolding. Scaffolding is a way to have an out of the box solution. Think of it like a house. Ruby is the housing materials and rails is the blueprint for the house. You can fill the house with different furniture, paint it different colors, etc. but if you want to build another house, you can use the same blueprint and go from there.
So, that’s a bunch of information on whats in rails and whats in ruby. I’m still learning about the differences, I know there are a lot of additional methods available with the addition of rails that aren’t available in just ruby. So, what to learn first? Personally, I think it is best to learn ruby first and then add rails. I think doing that makes it more clear what is ruby and then what is rails. However, the tutorials available for ruby on rails, I think, are much better because they are more interesting and you’re actually seeing something be built as you go through a tutorial. The ruby tutorials I’ve found cover lots of good basics, but I found them a little difficult to get through. And don't forget... if you get frustrated, just flip the table and you'll feel a little better.
You can find the slides here: http://www.slideshare.net/asheren/ruby-versus-rails
comments powered by Disqus