Need data from rails join table, has_many :through

前端 未结 3 922
眼角桃花
眼角桃花 2020-12-05 11:57

I have 3 tables - users, things, and follows. Users can follow things through the follows table, associating a user_id with a things_id. This would

3条回答
  •  無奈伤痛
    2020-12-05 12:15

    For people using rails 4, the usage of :order, :select, etc has been deprecated. Now you need to specify as follows:

    has_many :users, -> { select 'users.*, follows.is_admin as is_follow_admin' }, :through => :follows
    

提交回复
热议问题