Sha256: f46b93285c6b1bfe58537f36ad038df5e472efccbece701de3bf29b02b6e3c33

Contents?: true

Size: 790 Bytes

Versions: 2

Compression:

Stored size: 790 Bytes

Contents

class Admin::SitesController < Admin::ResourceController
  only_allow_access_to :index, :show, :new, :create, :edit, :update, :remove, :destroy, :switch_to,
    :when => :site_admin,
    :denied_url => { :controller => 'pages', :action => 'index' },
    :denied_message => 'You must have administrative privileges to perform this action.'
    
  def new
    model.hostnames.build
  end
    
  def switch_to
    site = Site.find(params[:id])
    if site
      redirect_to "http://#{site.hostnames.first.domain}#{request.port.to_s == '80' ? '' : ":#{request.port}"}/admin"
    else
      render :index
    end 
  end
  
  private

  def load_model
    self.model = if params[:id]
      model_class.find(params[:id], :include => [:hostnames])
    else
      model_class.new
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
radiant-vhost-extension-2.3.1 app/controllers/admin/sites_controller.rb
radiant-vhost-extension-2.3.0 app/controllers/admin/sites_controller.rb