Skip to content

Tenant models with String primary key(ID) instead Integer(ID) - Not working #82

@NarasimhaReddyY

Description

@NarasimhaReddyY

Hello, Am using milia with my rails app. It was working pretty fine until i changed my models primary key data type to String instead of Integer.

While signup a new tenant, it's not creating new tenant and user, Instead it's raising Milia::Control::InvalidTenantAccess: no existing valid current tenant error.

I tried to figured out why this is happening, then i found this is causing while creating new tenant for first time.

Here is the code from lib/milia/base.rb

      def acts_as_universal_and_determines_account()
        include ::Milia::InviteMember
        has_and_belongs_to_many :tenants

        acts_as_universal()

        # validate that a tenant exists prior to a user creation
        before_create do |new_user|
          if Thread.current[:tenant_id].blank? ||
              !Thread.current[:tenant_id].kind_of?(Integer) ||
              Thread.current[:tenant_id].zero?

            raise ::Milia::Control::InvalidTenantAccess, "no existing valid current tenant"

          end
        end
      end

Here we can see that it's checking for Integer type tenant_id. What if we would like to use some other data type instead Integer. ?? Thanks ...!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions