class PiePiece < ActiveRecord::Base
  belongs_to :pie
end

class PiePiece < ActiveRecord::Base
  belongs_to :pie
  has_one :users, through: :pie
  scope :user, ->(id) {
    joins(:users)
    .where('users.id = ?', id)
  }
end

Add user scope to pie pieces
Add user scope to pie pieces
