Class: Wco::UnsubscribesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Wco::UnsubscribesController
- Defined in:
- app/controllers/wco/unsubscribes_controller.rb
Overview
In order to have unsubscribes_url , unsubscribes must be in wco .
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
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 |
# File 'app/controllers/wco/unsubscribes_controller.rb', line 8 def create :open_permission, Wco @lead = Wco::Lead.find params[:lead_id] if( !params[:token] || @lead.unsubscribe_token != params[:token] ) render code: 400, message: "We're sorry, but something went wrong. Please try again later." return end @unsubscribe = WcoEmail::Unsubscribe.find_or_create_by({ lead_id: params[:lead_id], template_id: params[:template_id], campaign_id: params[:campaign_id], }) flag = @unsubscribe.update_attributes({ unsubscribed_at: Time.now, }) if flag flash_notice "You have been unsubscribed." else flash_alert "We're sorry, but something went wrong. Please try again later." end render layout: false end |
#do_unsubscribe ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/wco/unsubscribes_controller.rb', line 35 def do_unsubscribe :open_permission, Wco lead = Wco::Lead.find_by email: params[:email] if params[:token] == lead.unsubscribe_token lead.update({ unsubscribed_at: Time.now }) flash[:notice] = 'You have been unsubscribed!' render 'success', layout: false else flash[:error] = 'security token mismatch.' render 'error', layout: false end end |
#index ⇒ Object
48 49 50 51 52 53 |
# File 'app/controllers/wco/unsubscribes_controller.rb', line 48 def index :index, WcoEmail::Unsubscribe @unsubscribes = WcoEmail::Unsubscribe.all render '_table' end |
#new ⇒ Object
55 56 57 58 |
# File 'app/controllers/wco/unsubscribes_controller.rb', line 55 def new :open_permission, Wco render layout: false end |