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
// Google Analytics code to work with Turbolniks 5 | |
this.GoogleAnalytics = (function() { | |
function GoogleAnalytics() {} | |
GoogleAnalytics.load = function() { | |
var firstScript, ga; | |
window._gaq = []; | |
window._gaq.push(["_setAccount", GoogleAnalytics.analyticsId()]); | |
window._gaq.push(['_setAllowAnchor', true]); |
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, |
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
{ | |
"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
# lib/jsonapi/adapters/transactionless_mongoid_adapter.rb | |
module Jsonapi | |
module Adapters | |
# Mongoid transactionless adapter | |
# See https://github.com/jsonapi-suite/jsonapi_compliable/blob/master/lib/jsonapi_compliable/adapters/abstract.rb | |
# | |
# @author [Cyril] | |
# | |
class TransactionlessMongoidAdapter < JsonapiCompliable::Adapters::Abstract | |
def sideloading_module |
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
# Cf | |
# https://github.com/rollbar/rollbar-gem/issues/711 | |
# https://github.com/smartinez87/exception_notification/issues/413 | |
module ExceptionNotifier | |
class RollbarNotifier < ExceptionNotifier::BaseNotifier | |
def call(exception, options = {}) | |
@env = options[:env] | |
@data = (@env && @env['exception_notifier.exception_data'] || {}).merge(options[:data] || {}) | |
@current_user_data = (@env && @env['exception_notifier.current_user.exception_data'] || {}).merge(options[:current_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
class Moderation | |
belongs_to :content | |
end | |
class Content | |
has_many :moderations | |
end | |
class ModerationResource < ApplicationResource | |
type :'moderation' |
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
module Jsonapi | |
module Adapters | |
# Adapter for resources already loaded in memory | |
# | |
# The scope is meant to be something like an Array or Iterable of objects | |
# | |
# @example Time Series | |
# | |
# scope = [ | |
# OpenStruct.new(at: Time.now.noon, name: 'I ate'), |
OlderNewer