engine/app/controllers/locomotive/current_site_controller.rb

37 lines
804 B
Ruby
Raw Normal View History

module Locomotive
2011-07-06 18:48:04 +00:00
class CurrentSiteController < BaseController
sections 'settings', 'site'
skip_load_and_authorize_resource
load_and_authorize_resource :class => 'Site'
respond_to :json, :only => :update
def edit
@site = current_site
respond_with @site
end
def update
@site = current_site
@site.update_attributes(params[:site])
respond_with @site do |format|
format.html { redirect_to edit_current_site_url(new_host_if_subdomain_changed) }
end
end
protected
def new_host_if_subdomain_changed
if !Locomotive.config.manage_subdomain? || @site.domains.include?(request.host)
{}
else
{ :host => site_url(@site, { :fullpath => false, :protocol => false }) }
end
end
end
end