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/

On 12/02/2009, at 3:19 AM, Valentino Lun <rails-mailing-l...@andreas-s.net 
 > wrote:

>
> Dear all
>
> Refer to http://guides.rails.info/association_basics.html
>
> 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
> -- 
> Posted via http://www.ruby-forum.com/.
>
> >

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to