Reputation: 135
I've just added the Apartment gem to my existing project to make it a multi tenant application. after scaffolding a new model named Subdomain, with a single parameter 'title', for each user to enter his name and use the app independently of others, when I try to create a new subdomain on the 'new' page in the browser, I get the following error:
ArgumentError: prepare called on a closed database: rollback transaction
Extracted source (around line #30): (from the create method of my subdomains_controller.rb)
respond_to do |format|
**if @subdomain.save** <-- this is line #30, highlighted in the browser
format.html { redirect_to @subdomain, notice: 'Subdomain was successfully created.' }
format.json { render :show, status: :created, location: @subdomain }
else
My Subdomain Model:
class Subdomain < ApplicationRecord
after_create :create_tenant
private
def create_tenant
Apartment::Tenant.create(title)
end
end
I followed the steps to install from here.
I'm pretty new to rails so any help is welcome.
Upvotes: 3
Views: 320