标签:des style blog http color io os 使用 ar
一、如何定义关联
两个model之间常常会存在关联关系,为了解决这些关联引起的复杂操作问题,可以在model定义时定义其关联关系。如:实体customers和orders定义如下:
class
Customer < ActiveRecord::Base has_many:orders, dependent::destroyend class
Order < ActiveRecord::Base belongs_to:customerend |
belongs_tohas_onehas_manyhas_many :throughhas_one :throughhas_and_belongs_to_many:as:autosave:class_name:dependent:foreign_key:inverse_of:primary_key:source:source_type:through:validateRuby的model学习——Active Record Associations
标签:des style blog http color io os 使用 ar
原文地址:http://blog.csdn.net/u010515761/article/details/40143267