Created
November 12, 2012 02:50
-
-
Save ohayon/4057238 to your computer and use it in GitHub Desktop.
trying to change action of button
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create | |
@message = Message.new(params[:message]) | |
account_sid = 'AC99a8b8ee9bba15e33ee4cac8bb0e505a' | |
auth_token = 'f1adcf3b638369e574662fcad40e60f5' | |
if @message.save | |
begin | |
client = Twilio::REST::Client.new account_sid, auth_token | |
client.account.sms.messages.create( | |
from: '+16035093259', | |
to: @message.phone, | |
body: @message.message | |
) | |
render text: "Success!" | |
rescue Twilio::REST::RequestError | |
render text: "Try again with a valid number." | |
end | |
else | |
render :new | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment