diff --git a/doc/development/backend/ruby_style_guide.md b/doc/development/backend/ruby_style_guide.md index 27380805df99434d46084acc4c50b09284e88c9a..595e1871cdda0479921ba1c35e7ba39cbcb103c1 100644 --- a/doc/development/backend/ruby_style_guide.md +++ b/doc/development/backend/ruby_style_guide.md @@ -337,11 +337,13 @@ For more information, see: - [Functional patterns](https://gitlab.com/gitlab-org/gitlab/-/tree/master/ee/lib/remote_development#functional-patterns) - [Railway-oriented programming and the `Result` class](https://gitlab.com/gitlab-org/gitlab/-/tree/master/ee/lib/remote_development#railway-oriented-programming-and-the-result-class) -## ApplicationRecord / ActiveRecord model scopes +## ApplicationRecord / ActiveRecord + +### Model scopes When creating a new scope, consider the following prefixes. -### `for_` +#### `for_` For scopes which filter `where(belongs_to: record)`. For example: @@ -351,7 +353,7 @@ scope :for_project, ->(project) { where(project: project) } Timelogs.for_project(project) ``` -### `with_` +#### `with_` For scopes which `joins`, `includes`, or filters `where(has_one: record)` or `where(has_many: record)` or `where(boolean condition)` For example: @@ -374,7 +376,7 @@ scope :undeleted, -> { where('policy_index >= 0') } Security::Policy.undeleted ``` -### `order_by_` +#### `order_by_` For scopes which `order`. For example: @@ -386,3 +388,7 @@ Namespace.order_by_name scope :order_by_updated_at, ->(direction = :asc) { order(updated_at: direction) } Project.order_by_updated_at(:desc) ``` + +### Error translation / internationalization / externalization + +We should...