Class: Manage::ListsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/chaskiq/manage/lists_controller.rb

Instance Method Summary collapse

Instance Method Details

#clearObject



43
44
45
46
47
48
49
# File 'app/controllers/chaskiq/manage/lists_controller.rb', line 43

def clear
  @list =  Chaskiq::List.find(params[:id])
  @list.subscriptions.delete_all
  flash[:notice] = "We are importing in background, refresh after a while ;)"

  redirect_to manage_list_path(@list)
end

#createObject



60
61
62
63
64
65
66
# File 'app/controllers/chaskiq/manage/lists_controller.rb', line 60

def create
  if @list =  Chaskiq::List.create(resource_params)
    redirect_to manage_lists_path
  else
    render "new"
  end
end

#destroyObject



68
69
70
71
72
73
74
# File 'app/controllers/chaskiq/manage/lists_controller.rb', line 68

def destroy
  @list =  Chaskiq::List.find(params[:id])
  if @list.destroy
    flash[:notice] = "Destroyed succesfully"
    redirect_to manage_lists_path
  end
end

#editObject



24
25
26
# File 'app/controllers/chaskiq/manage/lists_controller.rb', line 24

def edit
  @list =  Chaskiq::List.find(params[:id])
end

#indexObject



8
9
10
11
12
13
# File 'app/controllers/chaskiq/manage/lists_controller.rb', line 8

def index
  @q = Chaskiq::List.ransack(params[:q])
  @lists = @q.result
  .page(params[:page])
  .per(8)
end

#newObject



20
21
22
# File 'app/controllers/chaskiq/manage/lists_controller.rb', line 20

def new
  @list =  Chaskiq::List.new
end

#showObject



15
16
17
18
# File 'app/controllers/chaskiq/manage/lists_controller.rb', line 15

def show
  @list =  Chaskiq::List.find(params[:id])
  @subscribers = @list.subscribers.page(params[:page]).per(50)
end

#updateObject



51
52
53
54
55
56
57
58
# File 'app/controllers/chaskiq/manage/lists_controller.rb', line 51

def update
  @list =  Chaskiq::List.find(params[:id])
  if @list.update_attributes(resource_params)
    redirect_to manage_lists_path
  else
    render "new"
  end
end

#uploadObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/chaskiq/manage/lists_controller.rb', line 28

def upload
  @list =  Chaskiq::List.find(params[:id])
  #binding.pry
  if path = params[:list][:upload_file].try(:tempfile)
    #binding.pry
    Chaskiq::ListImporterJob.perform_later(@list, params[:list][:upload_file].tempfile.path)
    flash[:notice] = "We are importing in background, refresh after a while ;)"
  else
    flash[:error] = "Whoops!"
  end
  rescue
    flash[:error] = "Whoops!"
  redirect_to manage_list_path(@list)
end