Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
NarasimhaReddyY opened this issue Dec 13, 2017 · 3 comments

Comments

@NarasimhaReddyY
Copy link

NarasimhaReddyY commented Dec 13, 2017

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 ...!

@dasibre
Copy link

dasibre commented Feb 27, 2018

I'm having the same issue, using uuid's

@NarasimhaReddyY
Copy link
Author

There is a open PR #73 to fix this, not yet merged.

@dasibre
Copy link

dasibre commented Feb 27, 2018

thats great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants