Solid foundation for new Rails projects, with all the essential features and best practices built-in. Opinionated to the tools we use.
gem install bundler
Homebrew dependencies:
All Homebrew dependencies are listed in Brewfile
, so you can install them all at once like this:
brew bundle install --no-upgrade
Then you can start the database servers:
brew services start postgresql
brew services start redis
run bin/setup
to setup. This should do a couple of things to get the app ready for development. You can also setup manually by running each command from the bin/setup
file.
Setup the RAILS_MASTER_KEY
credentials as secret on GitHub for CI to work. Settings > Secrets > New repository secret
Customize values in config/initializers/0_constants.rb
bin/dev
to run the app locallylocalhost:3000
to view the applocalhost:3000/rails/mailers
to view mailers preview locallylocalhost:3000/sidekiq
to view sidekiq dashboardHTML templating & components:
Backend:
Frontend:
Testing:
http://localhost:3000/users/auth/google_oauth2/callback
for development & similar for production with your domain.Checklist for things to update before you launch your app:
Update Privacy Policy and Terms and Conditions
Update AnonymizationService
to anonymize user data and relating records where personal information is stored when user requests to delete their account. This is important to comply with GDPR & other regulations. User data is scrambled but the record is kept for audit trail. Alternatively just delete the record if you want to completely get rid of the data immediately. Update the destroy method on RegistrationsController.
Add pages to config/sitemap.rb
file for sitemap generation.
If you don't want some pages to be indexed by search engines, add noindex
meta tag and update config/sitemap.rb
file to exclude those pages.
Onboarding flow with custom fields that you require user to fill out after sign up. Or disable the onboarding in the constants file.
We use Contentful (free plan) to manage blog posts. You can use Contentful for other content types as well and the structure is setup with webhooks and caching. Everything ready to go.
To get setup:
contentful space import --space-id <space_id> --content-file lib/templates/contentful.json
Deploy with an app.json file that helps Heroku pre-configure the application.
Install Heroku CLI and login to Heroku account (heroku login
).
The usual steps (create a Heorku app, deploy the code) plus the following:
Install addons:
Set config vars:
RAILS_MASTER_KEY
config var to decrypt credentials.yml.enc
fileHOST
config var to your domainRAILS_ENV
config var to production
Setup Buildpacks:
heroku buildpacks:set heroku/ruby -a <app_name>
(will take last priority)heroku buildpacks:add --index 1 https://github.com/heroku/heroku-buildpack-apt.git -a <app_name>
heroku buildpacks:add --index 2 https://github.com/brandoncc/heroku-buildpack-vips -a <app_name>
heroku buildpacks:add --index 3 https://github.com/gaffneyc/heroku-buildpack-jemalloc.git -a <app_name>
Run migrations:
heroku run rake db:migrate
Other setup:
https://<HOST>/contentful/webhook
with the secret token (Header as Authorization:Bearer
) that is set in the credentials file.rake active_storage:purge_unattached_blobs
to purge unattached file that are older than 2 days in active storage. - Run once a day.rake anonymize:users
to anonymize users data. - Run once a day. Important to delete user's data in our database. Give's time for them to change their mind before we delete their data.rake sitemap:refresh
to refresh sitemap. - Run once a day.