The Best Way to Learn Ruby on Rails
basix

The Best Way to Learn Ruby on Rails

Tutorial Details
  • Subject: Ruby on Rails
  • Skill Level: Basix
This entry is part 4 of 5 in the The Best Way to Learn… Session
« PreviousNext »

I come from a PHP background, but these days, I’m a full-time Rails developer. The difficulty for most people who make the switch lies in the learning curve that’s involved. Once you’ve become proficient in a language or framework, switching to a new one feels like an unnecessary (and time-consuming) challenge.

However, learning Ruby and Rails is actually pretty easy! It’s an incredibly powerful framework, and has a huge community pushing it along. So that begs the question: what’s the best way to learn Rails? Here’s a lesson plan.

This article details a full lesson plan that will get you up and running in no time! Follow each assignment below in order.


Assignment 1 - Work Through the “Try Ruby” Exercises

You might think learning Ruby is the most important step, and this is probably the part where everyone stops learning and just sticks with their current framework. Don’t do that! Don’t be scared to learn this language (or any language, really). Ruby is a fun, beautiful, and easy-to-learn language. Plus, you don’t really need to dominate the language 100% to be able to learn Rails. You just need the basics to begin.

Tryruby

Work through the Try Ruby exercises.

The most recommended tool for dipping into Ruby’s syntax is the Try Ruby website. It provides you with an interactive, web-based shell to play with the language. If you type help, you’ll be greeted with an interactive, 15 minute tutorial that’ll teach you the very basics of the language. Typing help 2 will take you to the second chapter of the tutorial.

Once you’ve worked through these exercises a couple of times, you’ll have a solid base. Personally, completing those two tutorials is all I initially did. The rest I’ve learned by creating web sites with Rails, Googling, and playing in IRB.


Assignment 2 - Install Ruby And Ruby on Rails

Run gem install rails to install Rails.

If you want to learn Rails, you’ll of course need to install it on your machine. There are multiple ways to do this, depending on your platform. If you’re on a Mac or a Linux-based computer, I recommend you use RVM. It’s a great tool to install Ruby. Refer to this article for installation instructions. If you’re on Windows, refer to RubyInstaller for Windows.

Next, you need to install Rails. To do so you should have RubyGems installed on your computer. If you used RVM to install Ruby, congratulations, you already have it! If you’re on Windows, refer here. To install Rails, run gem install rails, and, tada, you’re all set up!

Bonus Credit

rbenv is another increasingly popular method for installing Ruby. Research that as well.


Assignment 3 - Start with Jeffrey’s Introduction to Rails

The Intro to Rails Screencast I Wish I Had

In this 40 minute screencast, Jeffrey Way, Nettuts+ editor extraordinaire, teaches you all the basics you need to know to start developing with Rails.

By following this screencast, you’ll pick up a lot of information on topics including:

  • Models and generators
  • Test-driven development
  • ActiveRecord
  • Rspec and Capybara
  • Partials
  • …and plenty more

Assignment 4 - Take The Rails For Zombies Course

Zombies

I’ve always thought that learning by example is the best (and only) way to learn a language and a framework. A free and incredible course that you must take is Rails For Zombies, from the folks at EnvyLabs. It’s interactive, which means that, after watching each video, you’ll work through a handful of exercises.


Assignment 5 - Read A Book

Agile Rails

Purchase Agile Web Development with Rails.

Up until now, every tool I’ve given you has been free and interactive. Now, you need to purchase the book on Rails: Agile Web Development with Rails. It teaches you Rails by means of building a website from scratch. It goes through the very basics, creating controllers, models, scaffolding and even unit and functional testing, plus some AJAX! Be sure to buy the latest edition though!

Bonus Credit

Here’s some more popular Rails books that you might consider.


Assignment 6 - Build A Simple Blog

I know it sounds boring (it does to me), but it’s a great example and is used everywhere for a reason: it’s simple, you can finish that kind of tutorial in under an hour, and you learn the basics very fast. Now, if you read the book from assignment four, you should already have enough knowledge to build something like this. I encourage you to try and build one by yourself, from memory, without checking any tutorials on the subject. You can check some methods, look at how to validate some fields, etc., but the idea is that you need to put your knowledge to the test.

Blog Post

Build a simple blog that has support for comments. You don’t need to implement a fancy authentication system; just something simple to get started.

If You Do Get Stuck…


Assignment 7 - Add Some Complexity to Your Blog

Great! You’ve built yourself a basic blog. It certainly lacks some basic functionality one would expect from a blogging platform, but it’s a start. Let’s put more work into it.

Auth

Add a basic authentication system to your blog. This might sound somewhat complicated, but I won’t force you to do this completely on your own. There are a number of tools/gems available that will make the job a lot simpler, but they’re too advanced for your current skill level. Plus, we need you to keep learning the inner workings of a Rails application before relying on third-party tools.

Watch this screencast by Ryan Bates, where he covers the entire process of creating a basic authentication system from scratch. Apply that to your blog and make sure only you are able to create and edit posts, and delete comments (but make sure every one can create comments!).

Bonus Credit

  • Form validation is equally important, and isn’t difficult to implement. Refer to this screencast to make the task easier.
  • Refer to this article for more information on model associations in Rails. You can use the techniques outlined to add tagging to your blog.

Assignment 8 - Create Something on Your Own

This is where you need to get creative. For me, learning a language or framework by following tutorials works well up to a point. The first thing I created after I finished my sample blogging applications was an invoicing application. I found a simple design template online and started working on that. That allowed me to build something useful and according to my needs, while having actual fun!

If you want to follow in my footsteps, download the Twitter Bootstrap web app template (if you wish), so that you may spend more time programming than designing, and build yourself an invoicing application. Try to include authentication, clients, invoices (which should let the user apply a discount and taxes), and invoice items (which should include a description, quantity and price). This will teach you various important parts of a Rails application, such as nested forms.

Resources to Get You Started

  • Nested Model Form Parts One and Two: You’ll need this the moment you create an invoice, since invoice items will be “nested” inside the invoice form. Watch the videos to learn more.
  • Simple Invoicing App: This is the invoicing app I created to learn Rails. It’s built with Rails 3.0.4 though, so keep that in mind. It might be handy to check the models, associations, and JavaScript files.

Assignment 9 - Stay Up to Date …

Learning to program well is a never-ending process. That’s why you should subscribe to various blogs and Twitter accounts on the subject. Here’s a list of influential Rails people for you to follow on Twitter:

  • @dhh: The creator of Ruby on Rails. Posts insight on new releases and various tips.
  • @rbates: Producer of Railscasts, posts tips and tricks very often.
  • @rails: The official Ruby on Rails Twitter account. Follow them if you want insight on release dates, and development.
  • @rails_apps: They’re posting new Rails example apps pretty often, pretty useful.

And here are some websites you should subscribe to:

  • Railscasts: A must! Awesome screencasts about Ruby on Rails, best practices, tips, new gems, etc.
  • Asciicasts: If you’re not into watching videos, this site mimics Railscasts’ tutorials in text. It’s not as up-to-date as the first one, but it’s excelent.
  • Nettuts+: While we’re not 100% focused on Ruby and Rails, we’re posting more and more applicable content these days!
  • The Rails Way: Cool blog with various articles and tutorials.
  • Riding Rails: The official Ruby on Rails blog. They don’t post many tips or tutorials, but they announce official releases, so it’s good to read it often.
  • Planet Ruby on Rails: A Ruby on Rails blog aggregator. It’s no as filtered as reading one of the blogs I listed above, but it’s a good resource to check every once in a while.

Conclusion

This lesson plan will turn you into a Rails developer in no time. As you’ll find, Rails is an amazing framework, and it continues to get better every single year. I learned Rails using the same tools I recommended above; you should too!

If you have any questions, feel free to ask them in the comments or tweet me. And feel free to share your experience! Tell us how you learned Rails, what tools you used, and how you’re using it today.

Tags: basixRuby
Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • http://www.webmentor.cr/ Marco

    Aaahh greatness. Right now I am taking a course on Ruby on this 10 class course. It is great stuff, I love how simple it can be to develop on Rails. Hope I do well.

    Will give this a read. Thanks again!!! From your point of view, why are you now doing Rails only? Is it because of what I just said?

    • http://twitter.com/Synt4x Ian Murray
      Author

      It’s just a lot more comfortable and easier to create complex systems in no time, compared to some PHP frameworks I used. Besides, there are so many gems that make the job so much easier, it’s just better :)

      • Robato

        I love those “gems” too. Especially the ones that make is so much easier and better.. :)

        ………………….really?

      • Nick Larson

        Gems are the main reason I switched over. Takes 90% of the work out of doing so many things. Not even just in your app, but on the command line to help manage it. Ruby on Rails makes php feel like a frontend framework.

  • Nick Larson

    The best way to learn RonR, is by learning Ruby first! I’m glad I went back to the basics and learned ruby first, because I now understand things a hell of a lot better.

    I would suggest you start learning by creating simple gems that do things on the command line. That’s how I learned the most about the inheritance and how crazy it can get sometimes in ruby.

    Forget views, forget controllers, forget models. Just learn what ruby is and how it can help you. Then throw in the other stuff later.

    • G

      Agreed, I think the best way to learn rails is by learning ruby first. I learned the hard way.

    • http://astonj.com AstonJ

      Agree with most guys here – that the best way to learn Rails is by learning Ruby first.

      I’ve done an in-depth post about how to learn both Ruby and Rails here:

      Best way to learn Ruby & Rails

      It goes beyond just an introduction, well worth a look if you’re serious about learning Rails.

  • http://twitter.com/matthieu_tweets Matthieu

    Excellent article! Great content. Now we just need a “The Best Way to Learn Ruby” article :)

  • Daquan Wright

    If you already know how to program, I think you should gloss over the core language to understand its intricacies. Otherwise, the best way to learn any language is to build something in it, debug your program, and read the code of others. ;)

    I’ve started realizing this, regardless of whether it’s CSS or C++. Just dive in and have fun!

  • http://www.cell-designs.com Marcell Purham

    Very good article.Rails seems like a pretty good language to dive into. Lets see how the next year or so goes with it.

    • Maher Salam

      “Rails” is a framework written is “Ruby”, the most beautiful language on the universe :)

  • rsludge

    second assignment is awesome :)

  • http://codeforest.net Codeforest

    Ruby on Rails got ma attention after passing few lessons on Rails for Zombies. It is really interesting to work with and easy for a PHP developer to make a switch.

    I will try to make something of my own to see how it behaves in more complex situations.

    Thanks for this great resource.

  • Craw

    Here is also a nice video tutorial from lynda.com to start with rails 3 :
    http://www.lynda.com/Ruby-on-Rails-3-tutorials/essential-training/55960-2.html

  • http://koles46.pl KoleS46

    Yup! The article is gr8 but the spacebar isn’t working on the “try ruby!” site :D

    • http://twitter.com/Synt4x Ian Murray
      Author

      I noticed that backspace isn’t working either :( You can’t make any mistakes hehe :D

  • http://agencyzebra.com Max

    I’m a web designer – If I get going fulltime, how long would you reckon it would take for going from a programming noob to being able to create something that has the same functions as say, basecamp or freshbooks?

    1 year? Less? More?

    • http://twitter.com/jholyhead James

      Depends on how good you are at OOAD.

      The complexity of apps like Basecamp or Freshbooks isn’t in the language/framework that the application is built in, rather it’s in conceptualising the design of the model.

      Where rails and frameworks like it excel is that they get out of your way and allow you to concentrate on solving the business problems.

      If you are a good enough a developer to build a Basecamp clone in whatever language you currently work in, then I’d think you could learn enough about Rails and Ruby in a few months of serious, well directed graft to give it an attempt.

      There are no silver bullets, RoR wont turn a bad developer into a good one.

  • kasakka

    Assignment x: pull your hair out as you stumble upon the nearly unreadable API documentation.

    • Rob Charlwood

      I totally feel your pain!

      I work with Python and the Django framework in my day job but dabble a lot with Ruby on Rails in my spare time and in personal projects (I love both Python and Ruby). However, compared to the Django docs, the rails docs are almost unbearable! If I was a OOP newbie there is no way I could easily navigate them!

  • http://johnathanward.com John Ward

    I’ve been following this Ruby on Rails Tutorial. It’s really a really great walk through on how to build a rails app using test driven development.

    • http://blog.lastrose.com LastRose

      I agree entirely. Following it right now myself.

    • Anthony

      me too, excellent tutorial!

  • http://jammyspeaks.com Saurabh

    Hey,
    I got to learn a new language for my minor project. I was thinking about something that would help me in the long run. I have been considering, php, ruby (rails come as a an adjunct), javascript.

    So, what do you suggest?
    And should I take up ruby first before trying my hand at rails? And if yes, can someone provide a lesson plan for ruby too??

    I have nice experience in c++.

  • http://www.islamiceventfinder.com Islamic Event Finder

    My turn off all these days in switching to Rails is the deployment mess. I’ve been using CodeIgniter (PHP) framework and it’s just copy/paste and everything is there. No need for SSH, no Capistrano etc. It’s just plain simple (of course, PHP is messier than Ruby, I agree) and it makes it real easy to work on different machines with just a USB stick or Dropbox. If someone can point out how bad it is when it comes to deployment while using RoR I’ll try to make the switch.

    • http://twitter.com/Synt4x Ian Murray
      Author

      Deployment is actually more complicated than with PHP. I’ve tried most of the techniques to deploy, and by far the easiest is Heroku, although it is a little more expensive. Another alternative that is easy to configure is Apache with Passenger.

  • http://www.terrencebowman.com TJ

    Great stuff, thanks for the article. I am currently jumping into Ruby. I have to say that I really enjoy it so far!

  • http://www.vision-ps.de irfan

    whats the difference between ruby and ruby on rails

    • http://twitter.com/jholyhead James

      Ruby is a language, Rails is a web development framework that uses ruby as it’s language.

      Ruby is to rails as C# is to .NET (or as PHP is to CodeIgniter)

      • http://jared.com Jared

        C# is to ASP.NET

    • http://johnathanward.com John Ward

      Yep, rails is a framework. If you are going to build a web app the rails framework is the way to go. If you’ve never used a framework you should try it. Will save you tons of time writing things that are already built into the framework. Common function like database interaction, form validation, etc are already there for you to use.

  • http://devmoose.com JP

    woohoo fnially a RoR article! Keep them coming :)

    Btw, I’d love to see ror.tutsplus.com

    • http://twitter.com/Synt4x Ian Murray
      Author

      More Ruby on Rails articles are sure to come! Expect more in the near future :)

  • John Arnold

    How to learn Ruby on Rails – read a book about Ruby on Rails.

    Hmm…

    Reminds me of the old chestnut:

    “How to make a million dollars
    Step 1. Take a million dollars…”

  • http://jeremiahspear.info jerrylee

    Well, I have started down the road to ROR a few times. The one thing I never see addressed, is what happens after the setup. I had a client come to me with a badly built ROR application, it was basically a static site built on rails. Granted, I am new to Rails/Ruby, but all the books in the world could not get me up to speed on taking it apart and fixing it. If that would not have kicked my butt so bad, I would probably be further down the road. I agree the setup, installation, etc. is not a big deal, but afterwards, WOW.

    I am working on the book “Learning Ruby the Hard Way”. It’s pretty sweet, as well as the massive resources out there.
    Thanks for the article.

  • http://magentix.be Kristiaan Van den Eynde

    What I missed in this post is WHY you’d want to switch from php to Ruby on Rails.

    I’m used to building apps in either ‘pure’ php, CMS APIs (Drupal, WordPress, …) or CodeIgniter.
    What is so great about ruby/Rails that makes the (for example) php/CodeIgniter combo inferior?

    • Lee

      PHP !

    • http://aparadine.com Preston St. Pierre

      Speaking as a PHP developer who is learning rails I’d have to say that two things strike me as incentives to switch:
      1) Gems. Think of them as solutions wrapped in a package. They are numerous and easy to use.
      2) Easy test framework using rspec, capybara and FactoryGirl gems. I’ve always hated manual testing. This is much better.
      Those are the main ones I’ve found so far, but I’ve only been at it for a few days. There are likely ones I haven’t encountered yet.

  • http://www.web4you.co.in Web4you

    Good article found at correct time, I am going to learn ruby on rails and this can be a good start. Thank you

  • http://larzconwell.com Larz Conwell

    I started learning Ruby/Ruby on Rails a couple months ago and this is exactly how I started it! this is possibly the best way to learn the language IMO. This way you learn everything you could possibly need I even encourage you to ready more about Ruby itself to get more families with the methods you can use!

  • Aldo

    Hello!
    I’m interested in learning a new back-end language besides PHP, but I see that python is also an option

    Considering python and ruby on rails, which one do you recommend me?? which one have more future???

    I mean, I would like to dev mobiles apps some day

    thanks for your advice

    • igotrailed

      the popular framework for Python is Djano, and I think RoR is more popular and has larger more active community. I am learning Ruby on Rails, and you can use it create iOS apps with http://www.rubymotion.com/

  • http://8gramgorilla.com/ 8 Gram Gorilla

    Great article – it’s always good to read anything that encourages/helps people switch to RoR!

    I can definitely second Rails of Zombies! It’s an excellent resource and a lot of fun to work through. Otherwise, for me, the best thing was just reading a bit of a book and then getting stuck into a project. Nothing you teaches you like having to actually build something :)

  • Tim

    Great article! This is pretty similar to my learning experiences thus far. I started with Try Ruby, then did the Rails for Zombies tutorial and then did the Ruby on Rails Tutorial (http://ruby.railstutorial.org/). I’m going back and learning Ruby more in depth.

    Ruby is a much bigger hassle in the beginning to get everything set up and configured when compared to PHP, but once it’s all set up I definitely prefer RoR (and Ruby) to the PHP frameworks I’ve used.

  • http://www.blackmorewebsites.com.au Web Design Adelaide

    I learnt Ruby on Rails several years ago and the route I took was to get the book from Pragmatic Programmers and then start working on my own app. I found Ryan Bates railscasts to be invaluable also.

    Failing that Google is your friend. You can pretty much find any gem/plugin to do what you are thinking of if you know how to search properly.

    By far I learnt the most though by creating a full blown application that I personally needed.

  • Joaquim

    I recently wanted to learn a OOP language more in depth, and it was “almost” certain that It was going to be PHP. But just for curiosity I readed some articles about Ruby and RoR and it kept my eye right in the first aproach.
    I was amazed about the simplicity of the syntax, how fast can we do things, and the help that the community gives us.
    With “Try Ruby” and “Rails for Zombies” we have a good time learning, and get your first simple things assembled in no time.

  • http://www.youtube.com/watch?v=UQ8_VOGj5H8 Andrew

    I’ve created some basic rails 3.1 tutorials on Youtube if anyone is interested:

    http://www.youtube.com/watch?v=UQ8_VOGj5H8

  • http://fujitaiju.com/blog/ Fujiki Taiju

    Excellent post! Thanks!

  • http://www.brocknunn.com Brock Nunn

    I cannot tell you guys how much I like this series. Thank you , and keep up the great work!

  • http://www.dev-hq.net/ Joe

    This is awesome, nice article!

  • Jeremie

    Have you ever heard of the Ruby Koans? Built on test-driven development concept, it’s pretty neat when it comes to learning Ruby, and to be used as a reference for later: http://rubykoans.com/

  • http://www.loganabbott.com Logan

    I also highly recommend Michael Hartl’s Ruby on Rails tutorial at http://railstutorial.org. Definitely worth the money.

  • http://legoglatter.dk Sjove videoer

    I’ve in a long time wanted to learn Ruby on Rails, so thank you for this lovely post!

  • http://rorcasts.com dragosh

    Hi there,

    Nice list, I am learning rails/ruby and I have created a new website, my learning curve, for collecting all the podcasts about ruby and rails. I believe this could be a good way to keep us up to date with all de news about rails and ruby.

    It may be helpfull,

    Thanks for sharing.

  • http://rorcasts.com dragosh

    Check this out for more news on rails and ruby => http://www.rorcasts.com , podcast collector for all the ruby/rails podcasts available!

    It might be helpful.

  • http://kiranatama.com agus @ outsourcing company

    What about an IDE? Picking the right one is a key piece to learning any language.

    I use Eclipse, with the Aptana Studio 3 plugin for Ruby/Rails support…works brilliantly!

    • Chuba

      have u tried jetbrain Rubymine

  • http://www.austera-realidade.com zeh

    Nice post, but I think it was better if you say about ruby-learning not just Rails..

    It was better if you talk about, symbols, hashs, classes, atttrs_*, using a non-sql persistence, tests, fixtures, dsls and other stuffs u may know..

    I’m a java/php programmer, and I’m learning ruby too… so.. I think this things should be interesting, may be, more interesting then ruby for zombies (nice website)…

  • http://www.247webdevelopers.com/technologies.html anderson12

    Hiring ROR developer for your website development will help you save lots of your time, money and resources.

  • http://www.adelaidelocalseo.com.au seo services

    Ruby on Rails has always been helpful for me although I do find my self reverted back to php for web development from time to time.

    Thanks again for your insight with this article

  • http://betteroption.tk siddique

    nice guide to learn ROR step by step
    i really like the book given here to read

  • http://www.miax.nl Michiel

    Hi there,

    I’d like to built a website where you can upload an image (or choose one in a library) and modify it in an editor. Photofilters, text-ads, cutting and adding fancy stuff on it. The goal is to send a postcard with the image you’ve just made/chose and modified after paying a certain amount of money by wiretransfer as in Paypal.

    Is Ruby and/on Rails a good way of building a website/webapp like this?
    Kind regards,

    Michiel I Amsterdam NL

  • http://www.jeremysweazy.com Jeremy Sweazy

    Thanks for the post, Codeschools “Rails For Zombies” really is a nice way to start to learn RoR.

  • http://devs.helpliners.com helpLiners

    We are creating a service for people who are learning Rails (http://devs.helpliners.com/). We’d love to hear your thoughts about what types of problems you are finding along the way (http://bit.ly/NvKiUq). Thanks!

  • Justin

    codeStreak is a six-week program to learn Ruby on Rails, check it out.

    http://www.codestreak.com/

  • Imran

    awesome :)

  • AdrianKhoo

    For those who require a more structured approach, bootcamps and courses are great alternatives to self-learning. They force discipline and can help you ensure you get to a certain level of skill by a certain time.

    This Quora post provides a great list of bootcamps & academies around the world: http://www.quora.com/Programming-Bootcamps/What-are-the-short-term-3-12mo-development-bootcamps-academies-around-the-world

  • Anthony

    Cool blogpost. I’m a .NET developer currently dipping his toe in Ruby and RoR. I did the Rails For Zombies course and also did some Rails courses on hhttp://www.codeschool.com/ . For those interested in doing an intensive Bootcamp on Ruby and RoR, there is http://www.gotealeaf.com/

    For the moment I’m doing the excellent online (and free) tutorial by Michael http://ruby.railstutorial.org/ruby-on-rails-tutorial-book

    One question I have though, being used to programming in C# and having excellent debugging with Visual Studio IDE, is what the debugging experience is like in developing web applications with Ruby on Rails.

    Thanks for your advice,
    Anthony

  • http://twitter.com/Nick_Johnsn Nick Johnson

    It is certainly a very nice way to learn ruby
    on rails development
    , nice and informative article…..

  • jack

    @ irfan ruby on rails is something which used a lot nowadays for content management, blogs,online polls/surveys, developing widgets etc.