Min*_* Lo 6 activerecord ruby-on-rails-3
在对象模型中,我有
has_many :likes
has_many :hates
has_many :users, :through => :likes
has_many :users, :through => :hates
Run Code Online (Sandbox Code Playgroud)
如何获取喜欢的用户列表?例如object.users <---但是如何通过喜欢或讨厌来指定?
您需要为这两个不同的关联提供不同的名称.关于什么
has_many :likes
has_many :hates
has_many :likers, :through => :likes, :source => :user
has_many :haters, :through => :hates, :source => :user
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
494 次 |
| 最近记录: |