I had several requests in UserVoice to provide a Many to Many tutorial in Rails. This is a demonstration of how to put together a “has and belongs to many” association and a “has many through” association.
This is somewhat basic to Ruby on Rails, but important if you need to associate different models.
Over the last few weeks I’ve been using macvim and janus to write code. The more I learn about VIM, the more I love it.
It’s not so much that VIM does things that I find particularly natural or “better”, but rather it’s that it’s extremely powerful for opening, managing, and editing files. Each little trick I get brings me more and more to the place where I can code as fast as I can think.
The Pragmatic Programmer (book affiliate link) tells us to know our text editors. The more I get to know about my text editor, the better off I am.
CoffeeScript offers more than nice syntax for setting and managing data and functions. It also offers Classes, Inheritance, access to a ‘super’ method, Ruby-style string interpolation, easy variable and function bindings, and chained comparisons.
Here’s the code I showed in the video:
constructor: (@name) ->
move: (miles) ->
console.log @name + " drove " + miles + " miles."
class VWBug extends Vehicle
class Truck extends Vehicle
mater = new Truck "Mater"
herbie = new VWBug "Herbie"
Jamis Buck is a Ruby on Rails developer working at 37signals. He was part of the Rails Core Team, created the SQLite driver for Ruby, and created the Capistrano library for deploying applications in Ruby.
We talked about several things including:
the Maze algorithms he’s been working on on his blog
Tom Preston-Werner is one of the founders of Github.com. He’s a Ruby programmer who has successfully launched a business used by hundreds of thousands of programmers all over the world to host their programming projects. He is also the original developer behind Gravatar.
We also discussed open source software, contributing, hiring developers, and what makes Github such a great place to work. If you want some good pointers about how things should work at a development shop, I recommend this episode.