Class: WcoEmail::MessageStubsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- WcoEmail::MessageStubsController
- Defined in:
- app/controllers/wco_email/message_stubs_controller.rb
Instance Method Summary collapse
- #churn ⇒ Object
- #create ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#churn ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/wco_email/message_stubs_controller.rb', line 4 def churn @stub = WcoEmail::MessageStub.find params[:id] :churn, @stub if 'json' == @stub.format @stub.do_process_json ## postal server else @stub.do_process end =begin # WcoEmail::MessageIntakeJob.perform_async( @stub.id.to_s ) begin if 'json' == @stub.format @stub.do_process_json ## postal server else @stub.do_process end rescue => err @stub.update({ status: WcoEmail::MessageStub::STATUS_FAILED }) puts! err, "WcoEmail::MessageIntakeJob error" ::ExceptionNotifier.notify_exception( err, data: { stub: @stub } ) end =end flash_notice "Churned 1 stub." redirect_to request.referrer end |
#create ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/wco_email/message_stubs_controller.rb', line 36 def create @stub = WcoEmail::MessageStub.new params[:stub].permit! :create, @stub if @stub.save flash_notice 'saved.' redirect_to action: 'show' else flash_alert "Cannot save stub: #{@stub.errors.}" render 'new' end end |
#edit ⇒ Object
48 49 50 51 |
# File 'app/controllers/wco_email/message_stubs_controller.rb', line 48 def edit @stub = WcoEmail::MessageStub.find params[:id] :edit, @stub end |
#index ⇒ Object
53 54 55 56 57 |
# File 'app/controllers/wco_email/message_stubs_controller.rb', line 53 def index :index, WcoEmail::MessageStub @stubs = WcoEmail::MessageStub.all.page( params[:stubs_page] ) render '_index_table' end |
#new ⇒ Object
59 60 61 62 |
# File 'app/controllers/wco_email/message_stubs_controller.rb', line 59 def new @stub = WcoEmail::MessageStub.new :new, @stub end |
#show ⇒ Object
64 65 66 67 68 69 70 |
# File 'app/controllers/wco_email/message_stubs_controller.rb', line 64 def show @stub = WcoEmail::MessageStub.find params[:id] :show, @stub @client ||= Aws::S3::Client.new(::SES_S3_CREDENTIALS) @json = JSON.parse( @client.get_object( bucket: @stub.bucket, key: @stub.object_key ).body.read ) end |
#update ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'app/controllers/wco_email/message_stubs_controller.rb', line 72 def update @stub = WcoEmail::MessageStub.find params[:id] :update, @stub flag = @stub.update_attributes params[:stub].permit! if flag flash_notice 'success' redirect_to action: 'show' else flash_alert "Cannot save stub: #{@stub.errors.}" render 'edit' end end |