Ruby on rails 4 Rails和公寓-创建租户后重定向
我有一个创建租户的域模型Ruby on rails 4 Rails和公寓-创建租户后重定向,ruby-on-rails-4,apartment-gem,Ruby On Rails 4,Apartment Gem,我有一个创建租户的域模型 class Domain < ApplicationRecord after_create :create_tenant def create_tenant Apartment::Tenant.create(name) end end 类域
class Domain < ApplicationRecord
after_create :create_tenant
def create_tenant
Apartment::Tenant.create(name)
end
end
类域
创建租户“示例”后,我希望将浏览器自动重定向到
有人能帮我吗?答案比我想象的要简单。 成功创建租户后,只需重定向到包含子域名的url即可。 正在修改域控制器中的创建定义
def create
@domain = Domain.new(domain_params)
respond_to do |format|
if @domain.save
format.html { redirect_to "http://#{@domain.name}.lvh.me:3000/users/sign_in", notice: 'Domain was successfully created.' }
else
format.html { render :new }
format.json { render json: @domain.errors, status: :unprocessable_entity }
end
end
end
增加了这一行
redirect_to "http://#{@domain.name}.lvh.me:3000/users/sign_in"
重定向到特定url的步骤
重定向到用户\u登录\u url(子域:domain.name)
使用URL而不是路径是更优雅的rails方式。有更优雅的方式吗?