Class: Manage::ListsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Manage::ListsController
- Defined in:
- app/controllers/chaskiq/manage/lists_controller.rb
Instance Method Summary collapse
- #clear ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
- #upload ⇒ Object
Instance Method Details
#clear ⇒ Object
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 |
#create ⇒ Object
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 |
#destroy ⇒ Object
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 |
#edit ⇒ Object
24 25 26 |
# File 'app/controllers/chaskiq/manage/lists_controller.rb', line 24 def edit @list = Chaskiq::List.find(params[:id]) end |
#index ⇒ Object
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 |
#new ⇒ Object
20 21 22 |
# File 'app/controllers/chaskiq/manage/lists_controller.rb', line 20 def new @list = Chaskiq::List.new end |
#show ⇒ Object
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 |
#update ⇒ Object
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 |
#upload ⇒ Object
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 |