Adding Postgres and ActiveRecord
Getting started - adding dependencies to your project
Guides, tutorials and labs to accompany CMU's Programming for Online Prototypes (49-714).
Everything you need to know about building microservices for the web with Ruby and Sinatra.
These are the steps you should go through the sanity check your Sinatra application, deploy and test.
Load your Sinatra application locally by typing this code in your terminal window/command line:
ruby app.rb
Open the application in a browser using the information returned (something like localhost:4567
) and then go to the route we created so localhost:4567/sms/incoming
You can test your app by adding querystring parameters to check if the responses look OK: localhost:4567/sms/incoming?Body=Hi&From=+123456789
Note: Twilio will send the querystring parameters titleized (i.e. Body not body). Make sure your querystring is using the right casing.
If it works you should see a message like this:
<Response>
<Message>
<Body>
This is my message
</Body>
</Message>
</Response>
If you see a message like this and there’s no errors, we’re in business and can deploy. [Note: You should test your responses by changing the querystring.] Otherwise fix it…
If you do get an error:
.env
has the right info included in itrequire
statements are included in your app.rb
If the last step was successful and you have no apparent errors:
git push heroku master
and deploy your application to HerokuThen test it by sending an SMS to your Twilio Number. Fingers crossed your bot talks to you!
If it didn’t work, but it deployed OK, do the following
heroku open
, see if you get any application errors. If you did then the problem is with your code.
heroku logs
to see what’s happening on the server. This will let you know why the application crashed.GET
request. Alternatively, the code may have crashed or given an unexpected response to Twilio.