Sha256: 96d720077f59f8f987cd0395b127e07e7cc8c7931db14c1fbee44fcd8daf8c82
Contents?: true
Size: 1.83 KB
Versions: 1
Compression:
Stored size: 1.83 KB
Contents
require_dependency "storytime/application_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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
storytime-2.0.0 | app/controllers/storytime/dashboard/sites_controller.rb |