Class: Wco::SitemapPathsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/wco/sitemap_paths_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#home, #tinymce

Methods included from ApplicationHelper

#my_truthy?, #obfuscate, #pp_amount, #pp_currency, #pp_date, #pp_datetime, #pp_money, #pp_percent, #pp_time, #pretty_date

Instance Method Details

#checkObject



6
7
8
9
10
# File 'app/controllers/wco/sitemap_paths_controller.rb', line 6

def check
  @spath = Wco::SitemapPath.find params[:id]
  authorize! :check, @spath
  @spath.check
end

#clearObject



12
13
14
15
16
17
# File 'app/controllers/wco/sitemap_paths_controller.rb', line 12

def clear
  @spath = Wco::SitemapPath.find params[:id]
  authorize! :clear, @spath
  @spath.update_attributes({ results: [] })
  redirect_to request.referrer || sites_path(@spath.site)
end

#createObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/wco/sitemap_paths_controller.rb', line 19

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

#editObject



32
33
34
35
36
# File 'app/controllers/wco/sitemap_paths_controller.rb', line 32

def edit
  @spath = Wco::SitemapPath.find params[:id]
  @site = @spath.site
  authorize! :edit, @spath
end

#newObject



38
39
40
41
42
# File 'app/controllers/wco/sitemap_paths_controller.rb', line 38

def new
  @site = Wco::Site.find( params[:site_id] )
  @spath = Wco::SitemapPath.new site: @site
  authorize! :new, @spath
end

#showObject



44
45
46
47
48
49
# File 'app/controllers/wco/sitemap_paths_controller.rb', line 44

def show
  @spath = Wco::SitemapPath.find params[:id]
  @site = @spath.site
  authorize! :show, @spath
  render 'check'
end

#updateObject



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'app/controllers/wco/sitemap_paths_controller.rb', line 52

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