• Stars
    star
    137
  • Rank 266,121 (Top 6 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 9 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Rails 7 app template: Devise auth, Stripe billing, Tailwind CSS, admin panel, SEO helpers, etc

Speedrail

a Rails 7 boilerplate template by @ryanckulp, created to ship SaaS apps quickly. Learn how to use this at 24 Hour MVP.

features:

  • user authentication via Devise
  • design via Tailwind UI
  • user billing management via Stripe Checkout portal
  • safely manage ENV variables with Figaro
  • responsive toggle navbar w/ logic for login, signup, settings
  • SEO toolbelt via metamagic
  • rename your app in 1 command with Rename
  • increased debugging power with Better Errors
  • seed your DB in seconds via Seed Dump
  • production-ready DB via Postgres
  • easy API requests with HTTParty
  • Postmark for transactional emails, letter_opener for local dev mailers
  • script tag component (Google Analytics, etc)
  • testing suite via RSpec
  • cron job task scheduler (lib/tasks/scheduler.rake)
  • random data generation with Faker
  • Heroku <> Cloudflare HTTPS via lib/cloudflare_proxy.rb
  • background job queue via Delayed
  • paid subscriptions CRUD via Stripe Checkout
  • interactive charts via Chartkick
  • automated testing via GitHub actions + PR status check
  • Rubocop for code style enforcement and linting auto-fixes

Installation

  1. clone the repo
  2. bin/speedrail new_app_name
  3. plug ENV vars into config/application.yml

Development

bin/dev # uses foreman to boot server, frontend, and bg job queue

To keep your project up-to-date with the latest Speedrail changes over time:

# one time only
git remote add speedrail https://github.com/ryanckulp/speedrail.git

# when you notice Speedrail updates on GitHub
git pull
git fetch speedrail
git merge speedrail/master --allow-unrelated-histories
git checkout -b speedrail_updates
git add .
git push speedrail_updates
# use GitHub UI to handle conflicts

troubleshooting

ActionCable - to support WebSockets, run rails g channel channel_name --assets then add mount ActionCable.server => '/cable' to config/routes.rb. update cable.yml -> production: to include the following for Heroku to connect w/ Redis for ActionCable.broadcast:

ssl_params:
    verify_mode: <%= OpenSSL::SSL::VERIFY_NONE %>

Turbo Drive lazy-loads pages following form submission, causing script tags at the bottom of following views to not always load.

<!-- add data-turbo=false to form submission buttons if the following view needs a full render -->
<button data-turbo="false" type="submit" ...>Submit</button>

Testing

# headless
bundle exec rspec # run all tests inside spec/
bundle exec rspec spec/dir_name # run all tests inside given directory

# headed (in a real browser)
HEADED=TRUE bundle exec rspec

Code Quality

clean code helps keep projects manageable as they grow in complexity.

rubocop # checks your code against Ruby styling standards and calls out issues
rubocop -A # automatically fixes issues, can lead to false negatives
rubocop -a # automatically fixes "safe" issues, less aggressive than -A (uppercase)

Rubocop is an optional feature, however it runs automatically during GitHub CI checks. if you don't want to enforce the Rubocop styleguide, simply disable the Rubocop Check step inside ci.yml.

Deploying

figaro heroku:set -e production # you only need to do this once
heroku git:remote -a heroku_app_name_here # you only need to do this once
git push heroku master # deploys master branch
git push heroku some_branch_name:master # deploys non-master branch

If you get error: src refspec master does not match any the probable cause is that you're using a new Github repo which defaults to master being called "main." You can deploy to Heroku using the branch deployment strategy pushing main over master:

git push heroku main:master

or update your Heroku account to also default to main and then deploy with:

git push heroku main

note: Heroku must have 2 'dynos' enabled, web + worker, to process background jobs. if you don't need a queue, simply remove the worker task from Procfile and don't invoke .delayed functions.

Mailers

Speedrail is configured for transactional mailers by Postmark, which costs $10 /month for 10k emails. to activate this, set postmark_api_token inside application.yml and then verify your sending domain.

if you prefer a free email service for low volume applications, consider Resend. before installing it, first uninstall Postmark from Speedrail by 1) removing gem 'postmark-rails' from the Gemfile, 2) running bundle, then 3) deleting the following lines from application.rb:

config.action_mailer.delivery_method = :postmark
config.action_mailer.postmark_settings = { api_token: ENV['POSTMARK_API_TOKEN'] }

Contributing

anyone is welcome to submit a pull request with improvements of any kind.