开发者

How to do a Rails 3 join query?

开发者 https://www.devze.com 2023-01-31 07:48 出处:网络
I have the following model class User < ActiveRecord::Base has_many :assignments has_many :roles, :through => :assignments

I have the following model

class User < ActiveRecord::Base
  has_many :assignments
  has_many :roles, :through => :assignments
  has_one :profile
end

How wou开发者_JAVA技巧ld I do and active record query to select profiles of users with a particular role?


.includes(:relation) might be useful

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号