After developing .NET for a long, long time I felt the need to try something completely different.
Googling around the internet I had seen Ruby on Rails quite a few times already in the past few years. But back when it started I didn't exactly feel the need to learn a new language. But after hearing more about it on BubbleConf and other places I decided, what the heck, why not give it a shot and see where this takes me.
In this blogpost and in the next few blogposts I'm going to show you what I'm doing to learn Rails and how you can start building rails apps too.
How this series work
There's basically two approaches to learning a new language or thing. You can read a book about it and then start working with it. Or you dive in head-first and start building something and read books afterwards.
Depending on your personality, you may or may not like my style of learning. I am a hacker and I can only learn things inside-out when I get my fingers on them and break stuff
You have been warned! I will not explain theory in these blogposts, just some nice ways of doing things. I will point you to other blogs and manuals, but you will have to read them yourself if you are into such things.
Getting the goods
To start learning/building with Rails you need a few little things:
- An installation of Ruby on your machine
- A text editor (there's quite a few good ones out there)
- Git (because you are going to break stuff)
- The Ruby on rails gem
You can download Ruby from the following locations:
- http://rubyinstaller.org (Windows)
- http://net.tutsplus.com/tutorials/ruby/how-to-install-ruby-on-a-mac/ (Mac)
Pro tip(tm): Install the devkit too if you're on Windows. You can find it here: http://rubyinstaller.org/add-ons/devkit/
For mac users, make sure you install the Xcode command line tools. To do this you need to execute the following command in a terminal:
And the tools will install itself.
After you have installed Ruby on your system, you should be able to get the Rails gem installed. Start the terminal and execute the following command:
gem install rails
Your machine will rumble a bit and you should have rails installed on your computer.
Now that you have ruby and rails installed, the last thing you need is to install git. You can find the install files over on the git website: http://gitscm.com
Pro tip: Make sure you get the source tree app as well. It's a great tool for working with Git. I can really recommend it!
With everything installed, I could take you through the basics of building a rails app. But I'm not going to do that. There's people out there that are way better at this stuff than I am.
Instead I will send you around the internet for some great tutorials to start learning rails:
- Rails girls: http://guides.railsgirls.com/app/
- Rails guides: http://guides.rubyonrails.org/getting_started.html
I started learning from the rails girls tutorial and then moved on to the guides website offered on the rails website itself. This website contains a lot of in-depth information on how various concepts work. I found it a good resource once you learned the basics.
Learning the language
When you follow the guides for rails, you will quickly discover that it's really easy to learn. Most of not all of the stuff is configured with just a few commands. However, once I went beyond the basics of building a rails app, I ran into trouble.
Rails is cool on its own, but it still is ruby. And to get the most out of the experience I really recommend you learn Ruby.
The order in which you start learning Rails or Ruby isn't really that important since most guides explain really well what commands to use and what they mean. Learning Ruby with Rails however is really important. Once stuff starts to break, you will need to know Ruby to debug the problem and fix it.
I've found this guide to be helpful to learn the language: http://rubylearning.com/satishtalim/tutorial.html
I found that going through the guide start to finish wasn't really appealing. Instead of doing that, I grabbed chapters for things that I needed to get stuff working in my app.
Use good tools
If you know Ruby really really well, then you can do with just a text editor and your terminal. I however am no Ruby expert and I use good tools to cover up some of my short-comings.
Get some good tools to help you. You will thank yourself later for the time you've invested in getting some proper tools for the job.
My personal setup for working on Ruby projects is this:
TextMate isn't free, but a very good tool for writing various scripts and indeed Ruby. Even with just the basic installation of this tool you get so much bang for the buck. TextMate has great syntax highlighting and supports various extensions to make working with Ruby and Rails a breeze.
If you're looking to make TextMate your main tool for editing Ruby On Rails apps, then check out this blogpost: http://adventuresincoding.com/2010/05/10-textmate-bundlesplugins-to-boost-your-ruby-on-rails-development-productivity/
I didn't install all of the tools on there, because some tools I didn't need. I cherry picked a few bundles from the blogpost:
- Code beautifier
- Ruby On Rails
If you're working on Windows or don't want to use TextMate, then I can recommend Sublime Text. Again, not a free tool, although it's free if you can live with the nagging screens it gives from time to time.
Finally, if you have a bit more money to spend I can recommend RubyMine. It's a full blown IDE that offers everything that you need and don't need it all.
Aside from a good text editor I have only one tool that I want you to use. Use Git, even if you're developing locally. Commit all your changes in there every time you've build something to enrich your app. If something breaks and you don't know what to do, you can at least go back to when it worked
Git gives you free "Oh crap, undo" capabilities and the best thing yet: You can link your local repository to github and providers like heroku to deploy your app.
And that's basically everything you need to get started with Rails development.
I was really surprised at how easy it was to get started with Rails development. There's a boatload of guides out there and an even greater boatload of libraries and tools to make developing great apps easier.
Keep an eye out for part 2 in which I will show you how you can make your development environment even better.