This file contains hidden or 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
# encoding: utf-8 | |
=begin | |
Mongoid::Errors::ReadonlyDocument: | |
message: | |
Attempted to persist the readonly document 'Offer'. | |
summary: | |
Documents loaded from the database using #only cannot be persisted. | |
resolution: | |
Don't attempt to persist documents that are flagged as readonly. |
This file contains hidden or 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
require "mongo/collection/view" | |
# Add default "comment" for every request to MongoDB. | |
# https://github.com/mongodb/mongo-ruby-driver/blob/master/lib/mongo/collection/view.rb#L132 | |
Mongo::Collection::View.class_eval do | |
alias :mongo_collection_view_initialize :initialize | |
def initialize(collection, filter = {}, options = {}) | |
filter["$comment"] ||= default_comment | |
mongo_collection_view_initialize(collection, filter, options) |
This file contains hidden or 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
# encoding: utf-8 | |
require "bson/object_id" | |
BSON::ObjectId.class_eval do | |
alias to_json to_s | |
def as_json(*args) | |
to_s | |
end |
This file contains hidden or 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
require "active_support/inflector" | |
# http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-titleize | |
module LocaleDependentTitleize | |
def titleize(word) | |
return humanize(underscore(word)) if I18n.locale == :pl | |
super | |
end | |
end |
This file contains hidden or 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 RestClientLogResponsePatch | |
def process_result(res, &block) | |
response = super | |
log_response_with_body(response) unless res.is_a?(Net::HTTPRedirection) | |
response | |
rescue RestClient::Exception => exception | |
log_response_with_body(exception.response) | |
raise exception | |
end |
This file contains hidden or 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
# config/initializers/assets.rb | |
if Rails.env.development? | |
Rails.application.config.assets.precompile = [] | |
# Don't check if asset is precompiled on development, | |
# because building "precompiled_assets" list is taking quite long time. | |
# | |
# Default: https://github.com/rails/sprockets-rails/blob/89ba006950caba495954fbb1626919bfe4ee7838/lib/sprockets/railtie.rb#L31 | |
# "Called from asset helpers to alert you if you reference an asset URL that |
This file contains hidden or 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
# config/initializers/apartment.rb | |
require "apartment/reloader" | |
# skip Apartment::Reloader for assets | |
# (Apartment::Reloader is used only in development) | |
# https://github.com/influitive/apartment/blob/development/lib/apartment/railtie.rb#L43 | |
# https://github.com/influitive/apartment/blob/development/lib/apartment/reloader.rb | |
Apartment::Reloader.prepend(Module.new do | |
def call(env) |
This file contains hidden or 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
require "pry" | |
def pp(value) | |
pager = Pry::Pager::NullPager.new(STDOUT) | |
Pry::ColorPrinter.pp(value, pager, Pry::Terminal.width! - 1) | |
end | |
alias ap pp |
This file contains hidden or 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
# ByteBuf#getInt64 should return Fixnum not Bignum | |
# Issue: https://jira.mongodb.org/browse/RUBY-1189 | |
# Example: http://pastie.org/10978801#1,14,17,19,25 | |
# Gist: https://gist.github.com/kml/4c76c22df26a1fa372c97aff93e873ab | |
require "bson" | |
unless BSON::ByteBuffer.new(2200000227.to_bson.to_s).get_int64.is_a?(Bignum) | |
abort "#{__FILE__}: BSON::ByteBuffer#get_int64 already fixed! Remove this patch." | |
end |
This file contains hidden or 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
# https://github.com/rest-client/rest-client/blob/ac388df8b904b0ff839ac73496af5b75ab683076/lib/restclient/request.rb#L575 | |
# RestClient logs messages using RestClient.log << "message" | |
# that ignores default logger formatter | |
class RestClientLogAdapter | |
def initialize(logger: Logger.new(nil), level: :info) | |
@logger = logger | |
@level = level | |
end | |
def <<(message) |