I've got an Organization model and User model. Organization belongs to User with :creator alias:
class Organization < ApplicationRecord
belongs_to :creator, class_name: 'User', optional: true
end
User model is based upon devise with confirmation by email required. It has .confirm? method which returns boolean value.
So I want to filter all organizations with creators who have confirmed accounts. But when I try something like this:
Organization.find_by(creator: creator.confirmed?)
I get this error:
NameError (undefined local variable or method `creator' for main:Object)
How can I filter Organizations based on attributes of its creators?