Project

General

Profile

Actions

Refactor #6878

open

Replace default_scope with specific scopes for visibility

Added by Dominic Cleal over 10 years ago. Updated over 10 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Rails
Target version:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

default_scopes have caused a few bugs, mostly around sorting as the field used for sorting may not be available when the model is used in another query. When used to restrict visibility (e.g. #3272 for hidden users and taxonomies generally), it can break Rails associations as they assume a model can be looked up by ID (#6873).

Perhaps we should move to a more generally available scopes on every model? .visible, .sorted etc?


Related issues 2 (0 open2 closed)

Related to Foreman - Bug #6873: Error during db:seed from 1.4 to 1.6: undefined method `expire_topbar_cache' for nil:NilClassClosedDominic Cleal08/01/2014Actions
Related to Foreman - Bug #6964: Error on startup: "null value in column "user_id" violates not-null constraint"ClosedDominic Cleal08/06/2014Actions
Actions

Also available in: Atom PDF