Class: Occams::Admin::Cms::SitesController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/occams/admin/cms/sites_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



26
27
28
29
30
31
32
33
# File 'app/controllers/occams/admin/cms/sites_controller.rb', line 26

def create
  @site.save!
  flash[:success] = I18n.t('occams.admin.cms.sites.created')
  redirect_to occams_admin_cms_site_layouts_path(@site)
rescue ActiveRecord::RecordInvalid
  flash.now[:danger] = I18n.t('occams.admin.cms.sites.creation_failure')
  render action: :new
end

#destroyObject



44
45
46
47
48
# File 'app/controllers/occams/admin/cms/sites_controller.rb', line 44

def destroy
  @site.destroy
  flash[:success] = I18n.t('occams.admin.cms.sites.deleted')
  redirect_to action: :index
end

#editObject



22
23
24
# File 'app/controllers/occams/admin/cms/sites_controller.rb', line 22

def edit
  render
end

#indexObject



11
12
13
14
15
16
# File 'app/controllers/occams/admin/cms/sites_controller.rb', line 11

def index
  return redirect_to action: :new if ::Occams::Cms::Site.count.zero?

  @site   = ::Occams::Cms::Site.find_by_id(session[:site_id])
  @sites  = ::Occams::Cms::Site.all
end

#newObject



18
19
20
# File 'app/controllers/occams/admin/cms/sites_controller.rb', line 18

def new
  render
end

#updateObject



35
36
37
38
39
40
41
42
# File 'app/controllers/occams/admin/cms/sites_controller.rb', line 35

def update
  @site.update!(site_params)
  flash[:success] = I18n.t('occams.admin.cms.sites.updated')
  redirect_to action: :edit, id: @site
rescue ActiveRecord::RecordInvalid
  flash.now[:danger] = I18n.t('occams.admin.cms.sites.update_failure')
  render action: :edit
end