Learning Ruby and Rails, where would you start?
ontwik.com
ontwik.com
If you are new to Ruby or web dev I would suggest you first start with Sinatra (http://www.sinatrarb.com
That will give you an idea of what basic basic web dev looks like in ruby without the overhead of a huge framework to take in.
After you have a simple hello world running with Sinatra then see about adding an external gem. (Maybe the 'shotgun' gem mentioned on the Sinatra site) then learn about bundler http://gembundler.com and get Sinatra running with that setup. Look at the template languages (erb, haml) and play with those. When you find yourself playing with middleware then maybe look at rails and see what it has to offer. At this point you will already have a felling for how everything fits together with a rack based web app (Sinatra and Rails both use Rack) at a little lower level and I think you will have a better experience with rails and be more productive because of it.
EDIT: Submissions that have links to articles with questions marks in the title are annoying. Thought it was an ask HN at first.
Agreed, so did I!
In terms of Ruby itself, having picked it up myself only fairly recently I would recommend the following:
- unless you plan on maintaining someone elses code, jump straight into Ruby 1.9.
- hang out in the IRC channels, #ruby-lang and #sinatra on Freenode. The community is awesome and really helpful.
- the Sinatra video from Peepcode is really good
- for books, I would recommend "Cloning Internet Applications with Ruby" (ISBN 978-1849511063), "Beginning Ruby from Novice to Professional, 2nd Ed" (ISBN 978-1430223634) and of course the current version of the Pickaxe book (google it :)
- check out thechangelog.com regularly if you don't already
That's about it, good luck with it - I've found it fun so far and am currently developing my first web app on top of Sinatra which i hope to launch in a month or so!
I started with Rails first (someone sent me a PDF of an early Rails manual - I started skimming it about 8am, finished the entire book of 300+ pages by supper - not sure I even ate anything in-between).
After playing with Rails for a few months I started to look at Ruby itself - it's an awesome language.
But you're absolutely right, the best way to learn anything is to just jump in, and absolutely nothing wrong with Rails!
I also like Eloquent Ruby by Russ Olsen, it's a great way to learn how Ruby really works, written in a more approachable style than the Pickaxe.
Web resources:
- http://guides.rubyonrails.org
- https://github.com/edgecase/ruby_koans
Books:
- http://www.pragprog.com/titles/rails4/agile-web-development-... : Agile Web Development with Rails
- http://pragprog.com/titles/ruby3/programming-ruby-1-9 : Programming Ruby 1.9 (Pickaxe book)
- http://www.amazon.com/Rails-Way-Addison-Wesley-Professional-... : The Rails 3 Way
On a related note, I was recently directed to http://asciicasts.com/ for railscasts in text format... quite nice.
In some sense, it's an ideal and you could probably learn some of these things at the same time. That said, if you know nothing about HTML or SQL or <insert many other things here>, you're going to find Rails overwhelming and simply not get a lot of what you're doing. (Maybe that's fine too. Dive in, get lost, figure out parts of it. Lather, rinse, repeat. Some people probably learn this way, but some people no doubt like things a bit more orderly.)
[1] http://techiferous.com/2010/07/roadmap-for-learning-rails/
Also Railscasts is a fantastic resource.
Then, you and a friend should go build something!
It will help you greatly in understanding how and why rails works the way it does.
The rails internals contain lots and lots of "magic" stuff, which if rails is your first introduction to ruby, you will find you have trouble differentiating what is ruby and what is rails's magic.
I mostly picked things up by reading code and some blog posts whenever I came across an odd idiom.
Those guides are an exercise in best practice framework documentation.
About a year after that I tried O'Reilly's HeadFirst rails book and got much much more out of my effort.
The Ruby standard library is pretty big, and the language has a large number of syntax options, which means that there are often 30 different ways to do something, and you'll often see over half of those in the real world. Those various options can be undeniably handy at times, but even after working in Ruby for several years it's not uncommon to come across code that uses something you haven't seen before.
Rails is great, but it's quite large and also quite clever, and clever can be very difficult to understand unless you have a solid grasp of the language.
Starting with something simpler like Sinatra would be a great idea, but I'd still recommend going through a Ruby book first.
The most difficult thing for me learning Ruby on Rails was separating what cleverness was coming from Ruby and what cleverness was coming from Rails, learning as much as you can about ruby first would be a huge help.
Edit: tutorials didn't help me much; they all blabla about the crud stuff which is boring as you'll probably never use it. That's why I suggest not going that route.
Note: I had a bit* of Python scripting experience, and knew my way around HTML and CSS.*
1. A friend recommended SitePoint's Simply Rails 2. I went through that cover-to-cover, googling for where Rails 3 commands differ from Rails 2.
2. I used an old tutorial for rolling my own user model from scratch (still in the Sitepoint piece): http://www.aidanf.net/rails_user_authentication_tutorial
3. I ran "rails new" and started trying to code out what I was imagining. Anything that Simply Rails 2 didn't teach, I googled (e.g. FB/Twitter authentication with Omniauth, following/follower "friendship" models, Twilio integration, etc.).
If you're not coming into this with any scripting experience, I would absolutely recommend checking out http://tryruby.org/ first.
The Railscasts are a great resource as well - http://railscasts.com/episodes/archive
And a good starting resource for Ruby is the pickaxe book - http://www.amazon.com/Programming-Ruby-1-9-Pragmatic-Program...
- Bought a beginning Ruby book and gave it a quick perusal to get a handle on the fundamentals
- Went through Michael Hartl's amazing Rails Tutorial (I skipped over some of the detailed sections on testing with the intention of returning at a later point.)
- Finally, and most importantly, I converted an old PHP app into Rails. This helped me to see how what I wrote previously would fit into the Rails way of doing things.
What really astounds me is that people take ActiveRecord at face value and do stupid things such as Foo.all.sort_by(&:blah) or Foo.all.select {|x| x.stuff == "term"} and don't understand why it's such a bad idea.
http://en.wikipedia.org/wiki/Why_the_lucky_stiff
One of the developers in the video suggested to learn some Ruby first before diving into Rails.
Ruby's documentation culture is hair-tearingly frustrating. Half a paragraph, 3 examples covering the barest functionality of your module, and pages of badly-interfaced mechanically-extracted documentation made me want to punch the monitor several times a day. Oh, but it's got a pretty web-2.0tard design-minded web site, and of course gitardhub, which is especially a joy if it goes down during a deploy.
Think I'm exaggerating?
1. Head First Rails I first poohed this book but I had read 7-8 other books adn still was confused so I thought what the hell. I did each project several times and started making changes. Totally awesome especially the ajax integration parts. This is when I could actually make my own simple apps in less than a week.
2. I loved Agile Programming book - totally awesome. Not enough apps though. Great explanations. Gentle exposure to Ruby.
3. beginning novice to professional for ruby. I love this book. It is just plain fun. Good examples. I totally had fun with this. Peter is totally totally awesome - I wish he would write every tech book!!
Now you have the grounding, start making and asking questions.
What killed me was the UX/UI stuff. Then a friend suggested CSS Mastery book and using blueprint this got me clued in. Now I was not paralyzed. It was so awesome to see an app created in literally minutes.
I loved RoR - I miss it terribly. I disliked the community. Fanboyish. It was like being in all male high school with everyone thumping their chests and no help.
I still miss it very much. Whenever I code I first think in RoR then do it in php. My background was coldfusion, c#asp.net, java, etc. I need something dumb simple and php does the trick. And the people are nice and there are tons and tons of example to do anything. Also I needed something that is simple to deploy and maintain. Yeah yeah -RoR is easy to deploy - my first deployment took me several hours. Whereas php was minutes. In terms of sys admin and performance and optimization, I rather deal with php. As DBA, I do not really want an ORM. BTW when you feel good with RoR - check out Enterprise Rails - wow - good stuff on performance and optimization.
Thanks. This is in the pipeline.