Class: Wco::PublishersController

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

Overview

require ‘httparty’

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

#createObject

Alphabetized : )



8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/wco/publishers_controller.rb', line 8

def create
  @publisher = Wco::Publisher.new params[:publisher].permit!
  authorize! :create, @publisher
  if @publisher.save
    flash_notice "Created publisher"
  else
    flash_alert "Cannot create publisher: #{@publisher.errors.messages}"
  end
  redirect_to action: 'index'
end

#do_runObject



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

def do_run
  @publisher = Wco::Publisher.find params[:id]
  authorize! :do_run, @publisher

  @publisher.props = OpenStruct.new( JSON.parse params[:publisher][:props] )
  # @publisher.do_run binding
  @publisher.do_run

  flash_notice "Probably ok"

  redirect_to action: 'index'
end

#editObject



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

def edit
  @publisher = Wco::Publisher.find params[:id]
  authorize! :edit, @publisher
  @sites_list = Wco::Site.list
  @galleries_list  = Wco::Gallery.list
end

#indexObject



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

def index
  authorize! :index, Wco::Publisher
  @publishers = Wco::Publisher.all
end

#newObject



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

def new
  authorize! :new, Wco::Publisher
  @new_publisher   = Wco::Publisher.new
  @sites_list = Wco::Site.list
  @galleries_list  = Wco::Gallery.list
end

#updateObject



51
52
53
54
55
56
57
58
59
60
# File 'app/controllers/wco/publishers_controller.rb', line 51

def update
  @publisher = Wco::Publisher.find params[:id]
  authorize! :update, @publisher
  if @publisher.update params[:publisher].permit!
    flash_notice "Updated publisher"
  else
    flash_alert "Cannot update publisher: #{@publisher.errors.messages}"
  end
  redirect_to action: 'index'
end