Skip to content

Instantly share code, notes, and snippets.

View ToTenMilan's full-sized avatar

Grzegorz Milanowski ToTenMilan

View GitHub Profile
@ToTenMilan
ToTenMilan / apartment_location_autocomplete_controller.rb
Created October 28, 2023 19:36
Autocomplete the city/state/country name when user types it in its own locale, i.e. User types 'Nowy Jo', query returns 'New York'
module Remotes
class ApartmentLocationAutocompleteController < ApplicationController
def index
# https://github.com/shioyama/mobility/wiki/KeyValue-Backend#querying
# https://github.com/shioyama/mobility#querying
sql = ["
#{select_sql('apartments')} \
#{join_translation_sql('Apartment', 'state', 'string')} \
#{join_translation_sql('Apartment', 'country', 'string')} \
@ToTenMilan
ToTenMilan / stripe_webhook_signature_spec.rb
Last active April 4, 2024 18:35
Test stripe webhook signature outside of controller context
# Controlller
class Webhooks::StripeController < ApplicationController
skip_before_action :verify_authenticity_token
def index
stripe_service = StripeService.new(
request.env['HTTP_STRIPE_SIGNATURE'],
request.body.read
)