Answer the question
In order to leave comments, you need to log in
How to properly remove users in the rails model (with a tick disabled)?
I have a Users model
in the users table, there is an access field
that has the values \u200b\u200b(true, false)
Is it possible to cut off users who have false at the model level
Or do I need to register where (xxx, access = true) everywhere
Answer the question
In order to leave comments, you need to log in
class User < ActiveRecord::Base
default_scope ->{ where(access: true) }
...
end
class User < ActiveRecord::Base
scope :with_access, -> { where(access: true) }
...
end
User.with_access
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question