Skip to content

A template repository serving as the base for new Ruby on Rails Twilio sample apps

License

Notifications You must be signed in to change notification settings

TwilioDevEd/sample-template-rails

Repository files navigation

Twilio

Twilio Sample App Template

About

This is a GitHub template for creating other Twilio sample/template apps. It contains a variety of features that should ideally be included in every Twilio sample app. You can use GitHub's repository template functionality to create a copy of this.

Implementations in other languages:

.NET Java Python PHP NodeJS
TBD TBD TBD TBD Done

How it works

This is only a barebones Ruby on Rails application. Whenever, possible we should be using this. However, if you are using another framework like Sinatra that comes with their own standardized application structure, you should try to merge these by using the same README structure and test coverage, configuration etc. as this project.

Features

How to use it

  1. Create a copy using GitHub's repository template functionality
  2. Update the README.md and Gemfile with the respective values.
  3. Build your app as necessary while making sure the tests pass.
  4. Publish your app to GitHub

Set up

Requirements

  • Ruby version 3.0.x or later.
  • Bundler
  • Node.js version 14.15.4 - Rails 6 now uses webpack to serve frontend assets, so it needs Node to install it.
  • A Twilio account - sign up

Twilio Account Settings

This application should give you a ready-made starting point for writing your own appointment reminder application. Before we begin, we need to collect all the config values we need to run the application:

Config Value Description
Account Sid Your primary Twilio account identifier - find this in the Console.
Auth Token Used to authenticate - just like the above, you'll find this here.
Phone number A Twilio phone number in E.164 format - you can get one here

Local development

Before diving into the setup, it is RECOMMENDED to use Ruby with a version manager such as rbenv or asdf. This is specially important for MacOS users since OSX comes with a preinstalled Ruby version (usually an older version than the current) which may not be compatible with the new Rails 6 and it's generally better not to mess with system packages.

After the above requirements have been met:

  1. Clone this repository and cd into it
git clone [email protected]:twilio-labs/sample-template-rails.git
cd sample-template-rails
  1. Install gem dependencies
bundle install
  1. Install Node dependencies:
npm install
  1. Set your environment variables
cp .env.example .env

See Twilio Account Settings to locate the necessary environment variables.

  1. Configure pre-commit hooks
bundle exec overcommit --install
  1. Run the application
bundle exec rails s

Alternatively, you can use this command to start the server in development mode. It will reload whenever you change any files.

bundle exec rails s -e development
  1. Navigate to http://localhost:3000

That's it!

Tests

You can run the tests locally by typing:

bundle exec rspec

Cloud deployment

Additionally to trying out this application locally, you can deploy it to a variety of host services. Here is a small selection of them.

Please be aware that some of these might charge you for the usage or might make the source code for this application visible to the public. When in doubt research the respective hosting service first.

Service
Heroku Deploy

Some notes:

  • Heroku does not support SQLite, so if you want to deploy to Heroku you need to make the necessary changes on the project to use Postgres instead of SQLite.

Resources

Contributing

This template is open source and welcomes contributions. All contributions are subject to our Code of Conduct.

Visit the project on GitHub

License

MIT

Disclaimer

No warranty expressed or implied. Software is as is.

About

A template repository serving as the base for new Ruby on Rails Twilio sample apps

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published