Confuse with AR association

Dear all

Refer to rails.info

Why :physician and :patient some with (s), and some not...? It actually refer to the class name or table name? ** really confuse >_<. Can someone explain it? Is it a convention of rail? Thank you.

class Physician < ActiveRecord::Base   has_many :appointments   has_many :patients, :through => :appointments end

class Appointment < ActiveRecord::Base   belongs_to :physician   belongs_to :patient end

class Patient < ActiveRecord::Base   has_many :appointments   has_many :physicians, :through => :appointments end

Many thanks Valentino

It is the convention in Rails A Physician (singular) has many appointments (plural) An Appointment (singular) belongs to one patient (singular)

It depends whether there are more than one or not. A class is the
blueprint of an instance object. Thus a physician class describes one
object, of class physician. Has many means one physician has a
collection of some other kind of object. Belongs to means a physician
can be part of A collection of physicians for another class of object and is
therefore the other 'side' if you will.

Blog: http://random8.zenunit.com/ Learn rails: http://sensei.zenunit.com/