Starting with Rails
January 11th, 2008 | Published in Rails | 4 Comments
So as part of my new job I’m learning to use Rails, and by extension, the Ruby language. Both have been easier to pick up, at least initially, then I had expected. For that, I’m sure I have my experiences with Python and Django to thank: many concepts are similar, with sometimes similar syntax.
I started out by reading a book on Active Record, which is the ORM for Rails, and I would suggest that to anybody coming to Rails from a database background, because that way you’re not struggling to pick up both database concepts and Rails/Ruby syntax. Migrations? Good. Rake tasks? Good. The book itself is a decent practical guide, though not perfect, and will be a useful reference for me as I progress.
A very helpful book for me has been David Black’s “Ruby for Rails”, which is a great guide to syntax and concepts for people like me who are new to these things. On many levels, Ruby is elegant and makes a great deal of sense.
The other resource that I couldn’t do without is my colleagues, all of whom are much better-versed in Ruby and Rails than I am. Learning this in isolation would be a much greater challenge.
I’ve got a lingering preference for the url layout of Django, which allows uses regular expressions to construct any kind of url I’d like, and I’m sure I’ll get more comfortable with Rails’ routing and controller syntax as I get further into those areas. And yes, there is that magic, too, which has its ups and downs. Suffice to say that I’ll still be using Django for personal stuff, but you’ll see me experiment with Rails outside work as well.
In December I was in New York and went with one of the nytimes.com developers to the RubyNYC meeting, where features of Rails 2 were being discussed. It was an interesting presentation – much of it over my head – but one of the points that grabbed my attention was a brief discussion of the use of slugs in Rails. Slugs? Where have I heard that before? Nice to see a newspaper term work its way further into the Web.
January 11th, 2008 at 10:06 pm (#)
Heh, slugs are important. The rails default routing puts your objects’ ids in the URL. Ugh. I don’t want my sites to advertise how many of each object I have, or allow some bored coder to hammer on my server because he feels like scraping them all. It’s easy enough to fix with to_param on the model, at least.
January 13th, 2008 at 4:25 pm (#)
Peter,
In Rails 2.0, routing allows you to design whatever routes you want, and no longer ties your objects to a specific URL. I’m honestly not sure about pre-2.0.
January 18th, 2008 at 5:28 pm (#)
I haven’t read it myself, but I keep on hearing that “The Rails Way” is head and shoulders above the other Rails books.
January 19th, 2008 at 9:02 am (#)
My new boss (that’s Aron from above) recommended it as well, and it’s sitting on my nightstand. Hope to get to it this week.