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
# Concern to include in mongoid models that need database cache | |
# | |
# | |
module MongoidCacheable | |
extend ActiveSupport::Concern | |
class_methods do | |
# Create database fields to cache an attribute | |
# => Cache field, (Optional Cached_at DateTime field) | |
# |
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
{ | |
"data": { | |
"type": "profile", | |
"relationships": { | |
"educations": { | |
"data": [ | |
{ | |
"type": "profile/education", | |
"temp-id": 0, | |
"method": "create" |
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
```ruby | |
class User | |
embeds_many :attacker_performance | |
embeds_many :defender_performance | |
has_many :matches_as_attacker | |
has_many :matches_as_defender | |
end | |
class AttackerPerformance | |
embedded_in :user |
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
# Background : jsonapi-powered search controller | |
class MySearchController < JsonapiPoweredController | |
jsonapi resource: ::Public::Search::ProfessionalResource | |
def index | |
render_jsonapi(search_scope) | |
end | |
def search_scope | |
Searcher::SearchScopeProxy.new( | |
collection: Professional, |
NewerOlder