Sha256: ea15415c40a539ebf4233ad4cdfa761734c0f562b319cec2a777b3a4345a2574
Contents?: true
Size: 1.83 KB
Versions: 7
Compression:
Stored size: 1.83 KB
Contents
require_dependency "storytime/dashboard_controller" module Storytime module Dashboard class SitesController < DashboardController skip_before_action :ensure_site_exists, only: [:new, :create] skip_around_action :scope_current_site, only: [:new, :create] around_action :scope_current_site, unless: :skip_scope_current_site? before_action :set_site, only: [:edit, :update, :destroy] respond_to :json, only: [:edit, :update] def new @site = Site.new authorize @site end def edit authorize @site render :site end 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 def update authorize @site if @site.update(site_params) render :site else render :site, status: 422 end end def destroy authorize @site @site.destroy redirect_to storytime.dashboard_url(host: Storytime::Site.first.custom_domain), notice: t('flash.sites.destroy.success') end private def skip_scope_current_site? %w[new create].include?(params[:action]) && Storytime::Site.count == 0 end # Use callbacks to share common setup or constraints between actions. def set_site @site = Site.find(params[:id]) end # Only allow a trusted parameter "white list" through. def site_params params.require(:site).permit(:title, :post_slug_style, :ga_tracking_id, :root_post_id, :custom_domain, :subscription_email_from, :layout, :disqus_forum_shortname, :discourse_name) end end end end
Version data entries
7 entries across 7 versions & 1 rubygems