engine/app/controllers/locomotive/sites_controller.rb
2011-12-11 23:33:38 +01:00

34 lines
750 B
Ruby

module Locomotive
class SitesController < BaseController
sections 'settings'
respond_to :json, :only => [:create, :destroy]
def new
@site = Site.new
respond_with @site
end
def create
@site = Site.new(params[:site])
@site.memberships.build :account => @current_locomotive_account, :role => 'admin'
@site.save
respond_with @site, :location => edit_my_account_url
end
def destroy
@site = current_locomotive_account.sites.find(params[:id])
if @site != current_site
@site.destroy
else
@site.errors.add(:base, 'Can not destroy the site you are logging in now')
end
respond_with @site, :location => edit_my_account_url
end
end
end