简体   繁体   中英

Unable to create an user with “tenant”

I'm using a gem milia and devise.

class User < ActiveRecord::Base
  # ...
  acts_as_universal_and_determines_account
  #...
end

class Tenant < ActiveRecord::Base

  acts_as_universal_and_determines_tenant

  def self.create_new_tenant(params)
  #....
end

  create_table "tenants_users", :id => false, :force => true do |t|
    t.integer "tenant_id"
    t.integer "user_id"
  end

Only for the sake of testing, I want to create User:

u1 = User.new(:email => 'email@ggfdgfd.com', :password => 'password', :password_confirmation => 'password')

Tenant.create!(cname: 'cname1')

u1.save!

The error is:

> u1.save!
   (0.1ms)  begin transaction
  User Exists (9.3ms)  SELECT 1 AS one FROM "users" WHERE "users"."email" = 'email@ggfdgfd.com' LIMIT 1
   (0.1ms)  rollback transaction
NameError: uninitialized constant Control
    from /Users/alex/.rvm/gems/ruby-1.9.3-p547/gems/milia-0.3.34/lib/milia/base.rb:61:in `block in acts_as_universal'
.....

Looks a lot like this: https://github.com/dsaronin/milia/issues/5

And you have the old v0.3.34 of the Milia gem installed. Perhaps running bundle update milia would go a long way in solving this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM