Skip to content

Instantly share code, notes, and snippets.

View motoroller95's full-sized avatar

Искандар Гохар motoroller95

View GitHub Profile
@motoroller95
motoroller95 / production.rb
Created October 21, 2023 12:15 — forked from mudge/production.rb
How to configure Rails and Rack::Attack to use the real client IP when running behind Cloudflare
Rails.application.configure do
# Add Cloudflare's IPs to the trusted proxy list so they are ignored when
# determining the true client IP.
#
# See https://www.cloudflare.com/ips-v4/ and https://www.cloudflare.com/ips-v6/
config.action_dispatch.trusted_proxies = ActionDispatch::RemoteIp::TRUSTED_PROXIES + %w[
173.245.48.0/20
103.21.244.0/22
103.22.200.0/22
103.31.4.0/22
@motoroller95
motoroller95 / users.rb
Last active November 13, 2020 11:18 — forked from briu/users.rb
create two classes with same interfaces
# User attributes name surname
class User < ApplicationRecord
# attributes :id, integer
# attributes :name, string
# attributes :email, string
def log!
Log.create!(...)
end
@motoroller95
motoroller95 / transaction.rb
Last active October 2, 2020 11:46 — forked from briu/transaction.rb
transaction
ApplicationRecord.transaction do
user = User.create!
CalculatePayoutJob.perform_later(user)
// куча действий тут
end