-1

I've just create a new app with users (devise) and a model entreprise (a user could have many entreprise). This model entreprise has an attribute called subdomain. Each subdomain will have a tenant in Apartment

I would not like to create the tenant when user create Entreprise. I would like to have a listing views of Entreprise"In this view there should be a button to create tenant (after checking if tenant does not already exists).

thanks for your help as I m newbie in rails...

1 Answers1

1

I think you're asking how to create a tenant with the click of the button? If that's the case, you can just make it a simple link:

view

<%= link_to "add new tenant", create_tenant_path(enterprise: enterprise), method: :post %>

routes

post 'create_tenant/:enterprise' => 'tenants#create', as: 'tenant'

controller

...
def create
  Tenant.create(enterprise_id: params[:enterprise])
  redirect_to enterprise_path(params[:enterprise])
end

Or did I misunderstand what you're trying to do?

Yuri Gert
  • 103
  • 10