Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: Suggestions for Starting with Ruby on Rails?
26 points by NathanKP on Aug 14, 2010 | hide | past | web | favorite | 19 comments
I have been coding for about ten years, and consider myself to be very experienced with web app development in PHP. Recently, though, I discovered Heroku and it has left me with a strong desire to learn Rails.

The basics of the ruby language have been easy enough to master. It is just slightly different syntax and grammar. However, I have so far found it impossible to get started with Rails.

I have heard all the statements like "development in Ruby is 10x faster than development in PHP" but so far it is proving 10x harder to learn and 10x less documented.

Readjusting my thinking to work with the MVC framework is proving difficult, and its not helping that most of the tutorials I find are old or contain bugs that cause them to not work.

I find a nice looking tutorial, follow it perfectly and it fails because routes are not being set properly. Or I try to use gems such as restful authentication and they cause the server to fail on startup.

Ruby on Rails seems nice and I'm sure that once I get experienced with it I'll enjoy the 10x faster development speed, but so far it has proved 10x more frustrating to learn than PHP.

Do you have any tips or advice on learning Rails? Do you know of any decent (working) tutorials for learning MVC thinking?

I totally recommend this book : http://railstutorial.org/book There's also a free html version and it comes with rails2 and rails3 versions.

I'd get a stronger command of Ruby first. It'll help you, and Ruby is awesome. Rails may not be your thing even if Ruby is.

It's probably not the best way to learn Ruby, but the most fun way is definitely reading _why's poignant guide[1]. It's awesome and teaches you pretty well (you can find PDFs and such out there too).

Once you're satisfied with your command of Ruby:

I'm not really sure what the best way to get started is. I think RailsGuides[2] is supposed to be pretty good. The "getting started" page looks good and complete. When I started, the first thing I did is read the very-introductory parts of the Pragmatic Programmers' book[3], which is great. I didn't bother with the whole thing, just got the basics from it and then learned by doing, occasionally referring to it.

Once I read a few chapters of the pragprog book, I looked at official rails docs (I think it was guides.rubyonrails.org, but that site has evolved a lot since then), got started with something pretty simple, and googled if I had any trouble. For specific issues like getting exceptions, the api documentation[4] can be pretty useful. Though really, you should use apidock.com/rails because it's way more searchable (it's the same docs, plus some comments that apidock users have added, they just made a better search and made it less ugly).

Also, if Rails isn't doing it for you (especially if you do love Ruby), take a look at Sinatra and Padrino. There's of course way more plugins out there for Rails, but you can still use any gems (libraries), and it can be less annoying than Rails.

I'm not sure of any good ways to get used to MVC thinking. It wasn't that hard for me to get used to. What's the issue when it comes to MVC? Not sure where to put which code?

1: http://mislav.uniqpath.com/poignant-guide/

2: http://guides.rubyonrails.org/

3: http://pragprog.com/titles/rails4/agile-web-development-with...

4: http://api.rubyonrails.org/

EDIT: Forgot to mention that railscasts.com has awesome screencasts on all kinds of topics.

I also forgot to mention that restful_authentication is really old. Use authlogic.

Forgot to mention that railscasts.com has awesome screencasts on all kinds of topics. - Also, if you prefer to read them instead of watching, most are available on http://asciicasts.com/.

Also, a word of caution - http://guides.rubyonrails.org is currently based on rails 2.3. http://edgeguides.rubyonrails.org/ is probably the best place to look for the moment if you want to start with 3.0.

The edge guides actually follow the current master branch while the regular guides follow the current stable branch. Since 3.0 is kind of in limbo between the two (as an RC, it has it's own stable branch, but it hasn't been released yet), it's pretty much completely in sync with edge. Once it's released, everything should switch over to guides having info for 3.0 (the index page should list what version it's currently for).

...That was probably more than you ever wanted to know about Rails guides.

Thanks for the links.

For me the problem with MVC thinking is that I am used to my own system of MVC that I programmed for my personal PHP toolkit.

My version of MVC allows me to just write something like:

      <?php databaseInput("tablename",$id,"keyName"); ?>
      <?php databaseInput("tablename",$id,"keyName2"); ?>
It is very simple and works great with key value databases. My code system is designed to automatically detect the type of the key and output the appropriate control, even building dynamic AJAX controls such as input fields with attached google maps if the key is an address key.

After getting used to my own incredible easy to use MVC style system Ruby feels complex. I can use the generate script to build scaffolds, but then the generate script does so much that I can't really grasp all the connections.

For that matter I don't even see if it is possible to create a model with key value storage. The Rails generate scripts don't seem to have an option for that.

Perhaps you are correct that Rails might not be the thing for me, but I do really like Heroku, and want to be able to use it to enjoy the ease of scaling a web app by just dragging the slider upward. That means I need to build in Rails.

In addition, I feel that it will probably be better in the long-term to understand Rails thoroughly.


I just wanted to add that I have read _why's poignant guide and found it very useful, if a little less formal than I am normally used to. ;) I think that I have enough of a grasp on Ruby itself, and I have already developed a few standalone scripts. What I don't understand is all the things going on behind the scenes in the Rails code, and that is my stumbling block.

You may find some comfort in things like form_assistant[1] or formtastic[2].

In Rails 2, you can't have a model backed by a key-value store. Rails 3, which has a release candidate out, should make that doable.

Sinatra (with and without Padrino) also make it easy to use a k-v store. I think there's a good Redis library out there. I've used rufus-tokyo, which is a ruby library for Tokyo Cabinet, and it's solid. Though now there's Kyoto Cabinet. I'm not sure what the libraries are like for it.

1: http://github.com/rpheath/form_assistant

2: http://github.com/justinfrench/formtastic

Okay, it sounds like I'll have to try Rails 3. I'll check out the other github links that you gave me as well.

I had the EXACT same problem as you did until I really got a hold of understanding what MVC really meant.

I thought I understood it (yea, model, view, controller, gottit, so what). I figured it was about as important as a folder for css and a folder for scripts. But MVC is the core structure of how rails operates, so it is super important.

A friend of mine who is a rails developer helped me immensely by describing MVC as

Model - Anything that describes the structure of your data and interacts with the database

View - The layout and display of the page

Controller - gets the data from the model and passes it to the view.

I didn't bother with a 'restful' gem, as rail3 (which I decided to learn with) is already restful, so I'm not sure what that gem would have done for you. But it is true, some Gems won't work, I think that is just the way things are with Rails and Python due to different versions, and they being younger languages (though this can happen with PHP packages also I think, I never really used many of them).

I also dove in head first and went with MongoDB with MongoMapper, which I wanted to learn anyway, instead of using mysql and ActiveRecord.

The railscasts are actually quite good, though I actually learned by creating a twitter clone http://teachmetocode.com/screencasts/creating-a-twitter-clon... The tutorial wasn't flawless, but I am using MongoDB and Rails3, so I wasn't expecting it to work perfectly, but I eventually got it all working.

Part of my challenge with Ruby was that it seemed to do SO much for me that I didn't understand what it was doing, but it kinda worked. Then when I wanted to make changes, I didn't know enough about what it was doing to get it to work.

As far as Heroku, I'm yet to actually release a rails app, so I haven't even tried that. I decided to learn Rails because it seemed like every developer I've teamed up with over the past year has been a ruby dev person, and I figured it's easier for me to learn their language and add to my quiver than get them programming in PHP which some of them knew, but didn't really like.

After using Ruby, I can't say that I'm a complete convert, as I think I could still get much done in PHP at about the same pace, but I think we're moving into a rails world.

MVC does make sense when you get used to it. Best of luck.

Part of my challenge with Ruby was that it seemed to do SO much for me that I didn't understand what it was doing, but it kinda worked. Then when I wanted to make changes, I didn't know enough about what it was doing to get it to work.

This is my EXACT problem, but worded much better than I worded it. Thanks for the MVC description and the link to the screencast.

I'm learning RoR myself at the moment with this book:


It takes you through building various demo apps, using ruby, rails (separately at times), git and heroku. It doesn't bog you down in too much detail or theory, instead it introduces ideas in bite-sized packets and then shows the code relating to the theory immediately. I'm learning rails 3 from it, without ever having picked up much of rails 2. Highly recommended. The guy who wrote it, Michael Hartl, was in YC too.

I had a ton of the trouble learning rails and it actually took me a couple of attempts. The most affective thing for me was just starting a project and taking it slow trying to do everything the "rails way". Learning rails for me was a tremendously slow process but now it just makes sense and I can do things so much more quickly than I ever code with PHP. Rails is definitely easier to learn if you directly apply a guide to problem in my opinion, but maybe this is the case for all programming though.

More specifically, I have found railscasts and the official rails guides plus railsdoc to me infinitely useful. I usually look for a railscast to get the overview of the thing I want to use then look for a guide and then move into the rdoc for deeper understanding.

To get a good command over Ruby I would suggest reading the first two sections of Metaprogramming Ruby http://pragprog.com/titles/ppmetr/metaprogramming-ruby and reading the tutorial section of the Pick Axe book http://pragprog.com/titles/ruby3/programming-ruby-1-9

The first book will give you good coverage over what makes Ruby different. Most importantly it will give you an understanding of how the fancy stuff that Rails does is possible. The second book is a very good foundation book for Ruby. After this I think you'll be able to dive into Rails with much more confidence and understanding.

Rails has a hell of a learning curve. Ruby itself is mostly straightforward, but you're learning a new language and a new software stack at the same time - it's a lot more to take in than getting up to speed with PHP. It is opinionated software, and prefers convention over configuration, so until you start learning the conventions, it can be kind of confusing. That said, stick with it - once you get over the initial hump, it's very smooth sailing.

You're on the right track, you just may need a helping hand here and there. Try the #rubyonrails IRC channel on Freenode; it's very active, and tends to slant towards the newbie crowd. It may be just what you need.

Ruby is waay more than just a "slightly different syntax and grammar", and you can't really understand what's happening behind the scenes in rails until you understand the tools at work.

If you've got the basics of Ruby down, get this book and take it to the next level


As for the gems in rails..study their code, learn what they try to do, then program it yourself, else you might spend forever fighting with poorly documented and fragile gems, that were never really intended for long term production use anyway..

just my 2 cents..

I like your idea of programming the gems myself. Sometimes that is the only way to do it. I have already been experiencing the "poorly documented" and "fragile" nature of some of the gems out there.

second the book.

I just started it last week and have come to really appreciate ruby. My code doesn't look like python anymore :)

I strongly recommend PeepCode's "Rails 2 From Scratch" screencasts.. I'm not affiliated with them in anyway, just a very happy customer. They are only $9 each, but each one is over an hour long. Together they go through everything you need to get started with Ruby, Rails, and the MVC pattern.



Hmm, that does sound promising. I like the idea of Rails "from scratch". For me using script/generate is a great idea, but generating a scaffold doesn't teach me about what is going on behind the scenes. If Peepcode's tutorials show how to write the model, view, and controller from scratch then they will probably help me a lot.

Here's my strategy to learn a new framework/technology/language:

Start a dummy project while reading a great book on the subject. This way, you understand the book better because you're using the concepts you've just read.

Sometime, if it's a big framework/language, I like to start with a really small tutorial (See python or Arc tutorial for examples of what I'm talking).

Excellent roadmap for learning Rails:


Applications are open for YC Winter 2020

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact