You can replace it just like that, for the "?":
scope :accessible_by, -> (current_user) { where("loc_primary_email = :email OR loc_backup_email = :email ", email: current_user.email) }
But then the argument for where
must contain a hash, where the email key must be present.
You can check the docs for this, using an array of as argument (of course, you can omit the brackets);
Alternatively, you can use named placeholders in the template, and
pass a hash as the second element of the array. The names in the
template are replaced with the corresponding values from the hash.
User.where(["name = :name and email = :email", { name: "Joe", email: "[email protected]" }])
# SELECT * FROM users WHERE name = 'Joe' AND email = '[email protected]';
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…