lundi 21 mars 2016

Loop through subscribed and unsubscribed users

I have a problem with a Twilio app that I'm building. Right now I have an option for a user to be 'unsubscribed' but they still receive a message if they are. It makes sense that they do I just can't figure out how to change it. I tried a if else statment in the method that I will include in the bottom of this question. Is their a way I can loop through unsubscribed and subscribed with a if else? ```def send_message(msg)

if Person.subscribed == true
@twilio_number = ENV["TWILIO_NUMBER"]
@client = Twilio::REST::Client.new ENV["TWILIO_ACCOUNT_SID"], ENV["TWILIO_AUTH_TOKEN"]

@client.account.messages.create(
  from: @twilio_number,
  to: phone_number,
  body: msg
)
end

Right now if one person is unsubscribed it sends to nobody I just want it to send to subscribed.

Aucun commentaire:

Enregistrer un commentaire