Rails 多态
2016-03-24 00:00
423 查看
class Person < ActiveRecord::Base has_one :address, :as => :addressable end class Company < ActiveRecord::Base has_one :address, :as => :addressable end class Address < ActiveRecord::Base belongs_to :addressable, :polymorphic => true end
Address 有adressable_id addressable_type其中,addressable_type可以为Company或者Person
相关文章推荐
- What will the following polymorphic code output in C ++
- ADF12C EO polymorphic discriminator
- index and polymorphic
- Cannot proxy target class because CGLIB2 is not available
- CC2541 AirSync(5)——登录包
- SharePoint2010 Content Deployment Job Failed解决方案
- available()方法的使用总结
- light oj 1138 - Trailing Zeroes (III)《《二分》》
- 杭电 Problem1787 GCD Again
- hdoj 1867 A + B for you again【kmp,前缀与后缀的匹配】
- 感动 Mr.Snail 作品集
- LeetCode OJ 217. Contains Duplicate
- 在rails中使用bcrypt进行密码的加密
- UVALive 7483 Air Conditioned Minions
- vector中插入pair
- INSTALL_PARSE_FAIL_NO_CERTIFICATE 打jar包的时候遇到的问题。
- leetcode 11. Container With Most Water
- HDU 2457:DNA repair
- 杭电1787GCD Again(欧拉函数)
- [Leetcode 265]Paint House II