Rails scope with and without arguments

Public, Rails General

harrylevine

Created: Dec 11, 2019     Updated: Dec 11, 2019


Model scope with argument:

scope :for_company, ->(company_id) { where(company_id: company_id) }

Model scope without arguments:

scope :admins, -> { where(role: 'Admin') }