cheat sheets.

$ cheat rails_relationships
# has_many and belongs_to#
## Models ##
    class Customer < ActiveRecord::Base
      belongs_to :company
    end

    class Company < ActiveRecord::Base
      has_many customers
    end

## Migrations ##
    class CreateCustomer < Activerecord::Migration
      def self.up
        create_table :customers do |t|
          t.references :company
          ...
        end
      end
    end
Version 1, updated 1048 days ago.
. o 0 ( edit | history )
( add new | see all )