Class: Storytime::Dashboard::SitesController

Inherits:
Storytime::DashboardController show all
Defined in:
app/controllers/storytime/dashboard/sites_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#authenticate_user!, #current_user, #setup, #user_signed_in?

Methods included from Concerns::CurrentSite

#current_storytime_site

Methods included from Concerns::ControllerContentFor

#content_for, #content_for?, #view_context

Instance Method Details

#createObject



23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/storytime/dashboard/sites_controller.rb', line 23

def create
  @site = Site.new(site_params)
  authorize @site

  if @site.save_with_seeds(current_user)
    redirect_to storytime.dashboard_url(host: @site.custom_domain), notice: I18n.t('flash.sites.create.success')
  else
    render :new
  end
end

#destroyObject



43
44
45
46
47
# File 'app/controllers/storytime/dashboard/sites_controller.rb', line 43

def destroy
  authorize @site
  @site.destroy
  redirect_to storytime.dashboard_url(host: Storytime::Site.first.custom_domain), notice: t('flash.sites.destroy.success')
end

#editObject



18
19
20
21
# File 'app/controllers/storytime/dashboard/sites_controller.rb', line 18

def edit
  authorize @site
  render :site
end

#newObject



13
14
15
16
# File 'app/controllers/storytime/dashboard/sites_controller.rb', line 13

def new
  @site = Site.new
  authorize @site
end

#updateObject



34
35
36
37
38
39
40
41
# File 'app/controllers/storytime/dashboard/sites_controller.rb', line 34

def update
  authorize @site
  if @site.update(site_params)
    render :site
  else
    render :site, status: 422
  end
end