【发布时间】:2014-04-29 22:30:10
【问题描述】:
我有一个用户模型:
class User < ActiveRecord::Base
has_many :profile_label_values
belongs_to :company
end
个人资料标签值模型:
class profileLabelValue < ActiveRecord::Base
belongs_to :profile_label
belongs_to :user
end
和个人资料标签模型:
class ProfileLabel < ActiveRecord::Base
belongs_to :company
end
ProfileLabel 有两个属性is_deleted 和visible。我怎样才能让ProfileLabelValue 上的has_many 关联只返回那些ProfileLabels is_deleted = false 和visible = true 的值?
如何在我的has_many :profile_label_values 语句中创建一个条件,同时检查ProfileLabel 上的这两个属性?
【问题讨论】:
-
我们在聊天中解决了您的问题,关于 Rails 3.x 问题。有机会请采纳答案。
标签: ruby-on-rails ruby-on-rails-3 activerecord has-many model-associations