I have a model like this:
class Engineer < ActiveRecord::Base
default_scope { is_published }
scope :is_published, -> { where(is_published: true) }
end
Engineers can be authorized on the site via GitHub. And I want to give ability to authorize on the site for unpublished Engineers too. There are such filters in some controllers:
before_action :authenticate_engineer!, only: [:show]
But now after successfull authorization Engineer still can't pass these filters. How to say Devise that he should search between unscoped Engineers? Think, I should override some Devise method...
Solution was to override this Devise method in the Engineer.rb:
If I'm understanding you correctly, you want:
Do not use a default scope, and do something like this instead:
And in your controller:
Basically you're showing all engineers for authenticated engineers, and only the published ones for those not signed in using Devise.