Women in Technology

Hear us Roar

  Rolling with Ruby on Rails
Subject:   Great article, but one question
Date:   2005-10-26 22:12:46
From:   terry.sasaki
This is an awesome article as well as Ruby on Rails.
Finally I got into this.

BTW, in regards to Fig.49 and 50.
My understainding is it implies recipes-categories relationship is many-to-one relationship in the form of classes, not tables.
So, I modified the code a bit by using class names:

class Recipe < ActiveRecord::Base
belongs_to :category


class Category < ActiveRecord::Base
has_many :recipe #not 'recipes'

This works as well.
I'm a bit confused with class and table names.
Can anybody give me any suggestion?

Full Threads Oldest First

Showing messages 1 through 2 of 2.

  • Curt Hibbs photo Great article, but one question
    2005-10-27 03:49:20  Curt Hibbs | O'Reilly AuthorO'Reilly Blogger [View]

    In many cases (although not all) Rails is smart enough to accept singular or plural as you just discovered with "has_many". That way you can choose the form that reads the best.

    In this case I would say "has_many: recipes" because it reads more naturally.
    • Great article, but one question
      2005-10-27 16:41:20  terry.sasaki [View]

      Thanks curth,

      Well, so we must use a class name here, but it could be singular or plural.
      Wow, I will use more intuitive 'recipes' of course from now on.