-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Sequel refinement for pg_array_op
- Loading branch information
Showing
5 changed files
with
18 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
require 'models/parallel' | ||
require 'sequel/extensions/core_refinements' | ||
|
||
class Person < Sequel::Model | ||
using Sequel::CoreRefinements | ||
|
||
# FIXME: this should be put somewhere else so we don't have dependency on other model | ||
# see also ApiHelper#user_allowed? | ||
def self.teacher?(username) | ||
teacher_ids = Sequel.pg_array(:teacher_ids) | ||
DB.select(1) | ||
.where(Parallel.where(teacher_ids.contains([username])).exists) | ||
.where(Parallel.where(:teacher_ids.pg_array.contains([username])).exists) | ||
.any? | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters