Class: Ishapi::EmailUnsubscribesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Ishapi::EmailUnsubscribesController
- Defined in:
- app/controllers/ishapi/email_unsubscribes_controller.rb
Instance Method Summary collapse
Methods inherited from ApplicationController
#exception, #home, #long_term_token, #vote
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 |
# File 'app/controllers/ishapi/email_unsubscribes_controller.rb', line 8 def create :open_permission, ::Ishapi @lead = 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 = ::Ish::EmailUnsubscribe.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 end |