class Wco::SitemapPathsController
def check
def check @spath = Wco::SitemapPath.find params[:id] authorize! :check, @spath @spath.check end
def clear
def clear @spath = Wco::SitemapPath.find params[:id] authorize! :clear, @spath @spath.update_attributes({ results: [] }) redirect_to request.referrer || sites_path(@spath.site) end
def create
def create authorize! :create, Wco::SitemapPath @spath = Wco::SitemapPath.new params[:spath].permit! if @spath.save flash_notice 'Success.' redirect_to wco.site_path(params[:spath][:site_id]) else flash_alert "Could not save spath: #{@spath.errors.full_messages}" render 'new' end end
def edit
def edit @spath = Wco::SitemapPath.find params[:id] @site = @spath.site authorize! :edit, @spath end
def fix_params
def fix_params if params[:spath][:selectors].present? params[:spath][:selectors] = params[:spath][:selectors].split(',').strip else params[:spath][:selectors] = [] end end
def new
def new @site = Wco::Site.find( params[:site_id] ) @spath = Wco::SitemapPath.new site: @site authorize! :new, @spath end
def show
def show @spath = Wco::SitemapPath.find params[:id] @site = @spath.site authorize! :show, @spath render 'check' end
def update
def update @spath = Wco::SitemapPath.find params[:id] authorize! :update, @spath flag = @spath.update params[:spath].permit! if flag flash_notice 'Success' redirect_to site_path(@spath.site) else flash_alert 'No luck.' render action: 'edit' end end