Using Ros Apartment gem with ruby 3.0.0

1k views Asked by At

After updating ruby version from 2.7.4 => 3.0.0 seems that ros-apartment gem cannot switch between tenants.

NoMethodError (undefined method `decode' for URI:Module):
  
lib/rescued_tenant_elevator.rb:10:in `block in call'
lib/rescued_tenant_elevator.rb:10:in `call'

After searching in documentation of ros-apartment seems that the problem is on generic call after calling @app.call(env)

My class for switching tenants

require 'apartment/elevators/subdomain'

class RescuedTenantElevator < ::Apartment::Elevators::Subdomain
  def call(env)
    super
  rescue Apartment::TenantNotFound
    [302, { 'Content-Type' => 'text/hml', 'Location' => Rails.application.routes.url_helpers.root_url }, self]
  end

  # needed to work
  def each
  end
end

Any idea ??

1

There are 1 answers

1
Egli On

Until apartment gem release any change about that i fixed it re-adding the URI methods in init

module URI
  def URI.decode(url)
    url
  end

  def URI.escape(url)
    url
  end
end