Class: CmsAdmin::SitesController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/cms_admin/sites_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



21
22
23
24
25
26
27
28
# File 'app/controllers/cms_admin/sites_controller.rb', line 21

def create
  @cms_site.save!
  flash[:notice] = 'Site created'
  redirect_to :action => :edit, :id => @cms_site
rescue ActiveRecord::RecordInvalid
  flash.now[:error] = 'Failed to create site'
  render :action => :new
end

#destroyObject



39
40
41
42
43
# File 'app/controllers/cms_admin/sites_controller.rb', line 39

def destroy
  @cms_site.destroy
  flash[:notice] = 'Site deleted'
  redirect_to :action => :index
end

#editObject



17
18
19
# File 'app/controllers/cms_admin/sites_controller.rb', line 17

def edit
  render
end

#indexObject



8
9
10
11
# File 'app/controllers/cms_admin/sites_controller.rb', line 8

def index
  return redirect_to :action => :new if Cms::Site.count == 0
  @cms_sites = Cms::Site.all
end

#newObject



13
14
15
# File 'app/controllers/cms_admin/sites_controller.rb', line 13

def new
  render
end

#updateObject



30
31
32
33
34
35
36
37
# File 'app/controllers/cms_admin/sites_controller.rb', line 30

def update
  @cms_site.update_attributes!(params[:cms_site])
  flash[:notice] = 'Site updated'
  redirect_to :action => :edit, :id => @cms_site
rescue ActiveRecord::RecordInvalid
  flash.now[:error] = 'Failed to update site'
  render :action => :edit
end