engine/app/controllers/admin/sites_controller.rb

48 lines
997 B
Ruby

module Admin
class SitesController < BaseController
sections 'settings'
def new
@site = Site.new
end
def create
@site = Site.new(params[:site])
if @site.save
@site.memberships.create :account => @current_account, :admin => true
flash_success!
redirect_to edit_admin_my_account_url
else
flash_error!
render :action => 'new'
end
end
def destroy
@site = current_account.sites.detect { |s| s._id == params[:id] }
if @site != current_site
@site.destroy
flash_success!
else
flash_error!
end
redirect_to edit_admin_my_account_url
end
protected
def new_host_if_subdomain_changed
host_from_site = "#{@site.subdomain}.#{Locomotive.config.default_domain}"
if request.host == host_from_site
{}
else
{ :host => "#{host_from_site}:#{request.port}" }
end
end
end
end