4 ms·
First things: You need to know MVC, and you need to know Ruby. MVC takes a little while to wrap your brain around if you've only ever done things like PHP. Ther
by inklesspen 19y ago
First things: You need to know MVC, and you need to know Ruby. MVC takes a little while to wrap your brain around if you've only ever done things like PHP. There isn't really a great overview document for MVC, but if you do some google searching and wikipediaing, you can find some stuff. Understand what goes in the controller, and in the model, and in the view, and why we bother to separate them.
Then learn Ruby. There are a bunch of resources for this. Why's Poignant Guide is hilarious, but rather opaque. I recommend a book by David Black called Ruby for Rails, but I'm sure O'Reilly has some fine books too.
Now you're ready to start learning Rails. The online documentation is usually poorly organized -- at best. If you can afford it, pick up Agile Web Development with Rails. It's in its second edition now, and is much much better at introducing you to rails than any online resource I've seen. Maybe someone else here can recommend an online tutorial I haven't seen, but they seem to generally be more out of date than the books, rather than the other way around.
- edawerd 19y agoDoes Agile Web Development with Rails have a section on learning Ruby? I'm wondering if I can kill two birds with one stone with this behemoth of a book
- inklesspen 19y agoNot really, sorry. If you know Python or a similar language well, you can probably get by without a dedicated Ruby resource, because AWD does have lots of examples, and it has a 13-page ruby tutorial appendix. But I wouldn't recommend it.
- damir 19y agoMost of the things in Ruby are objects, so you can try using plain english (ie. my_array.length, my_array.each {|element| puts element, ...). If you get stuck, here's two links I use the most: http://www.rubycentral.com/ref/ http://www.rubycentral.com/ref/ http://api.rubyonrails.org/ http://api.rubyonrails.org/
- jamesbritt 19y agoThat reference link refers to Ruby 1.6. You'll find more current info at http://www.ruby-doc.org http://www.ruby-doc.org
- nostrademons 19y ago"MVC takes a little while to wrap your brain around if you've only ever done things like PHP." Good PHP code typically uses a MVC architecture as well. The model is the database, the controller consists of PHP files that take your $_GET and $_POST parameters and grab result sets out of the database, and the view is PHP files with no PHP tags besides your basic echoing, looping, and conditional HTML inclusion. Some people prefer to use a templating system like Smarty, which gives a prettier syntax but is conceptually the same. Good examples are vBulletin, Phorum, and Pligg (well, the Pligg codebase has some other issues, but it's a MVC architecture). Bad examples might be stuff like PhotoPost that mashes all the code together. I highly suspect successful PHP websites like Flickr and FaceBook use a MVC architecture too, but I have no inside knowledge of their codebase. Rails isn't that hard to learn if you've seen PHP code written like that. A Rails controller is like a collection of PHP entry pages: each method responds to a particular URL, and is responsible for populating dynamic content and rendering a template (which implicitly defaults to the method name). An ERB template is just like a PHP page, but with embedded Ruby instead of embedded PHP. An ActiveRecord object is like a PHP result set, except that changes to the object can be easily reflected back to the database. That's basically Rails in a nutshell.
- edawerd 19y agoThanks inklesspen, I did exactly what you advised. Devoured through Ruby for Rails, and I'm about half way through Agile Web Development. I really feel like I'm getting a good understanding of RoR!