Active Record Relationships: A Ruby on Rails Cheat Sheet

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Favorites, Groups & Events

    Active Record Relationships: A Ruby on Rails Cheat Sheet - Presentation Transcript

    1. onysHhoips dsh
Reegluaetbiy Am y venReilccoert e t id Actuiby o Ra s h a note: has_many and has_one aR work identically except for the number of relationships. both go on the table/model that does not feature the foreign key belongs to has many create table customers ( create table companies ( id int auto_increment primary key, id int auto_increment primary key, name varchar(75), name varchar(75) company_id int ) ) customers belongs_to :company companies has_many :customers company_id id has and belongs to many create table articles ( create table articles_authors ( create table authors ( id int auto_increment primary key, author_id int, id int auto_increment primary key, name varchar(75), article_id int name varchar(75) body text ) ) ) articles authors has_and_belongs_to_many :authors has_and_belongs_to_many :articles id articles_authors id article_id author_id note: the articles_authors table is implicit due to the two models that call habtm, and it does not require a model of its own. when making implicit mapping tables such as this, it must be named tablea_tableb where a is first in alphabetical order. © 2005 Amy Hoy / amy@infocookie.com / www.slash7.com MIT License — see http://www.slash7.org/cheats/license.html
    SlideShare Zeitgeist 2009

    + guest918670guest918670 Nominate

    custom

    390 views, 0 favs, 0 embeds more stats

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 390
      • 390 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 0
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories