Skip to content

Instantly share code, notes, and snippets.

@clarkware
Created November 2, 2021 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clarkware/3ff0592dd922d4b7e1275e4afd51cc5a to your computer and use it in GitHub Desktop.
Save clarkware/3ff0592dd922d4b7e1275e4afd51cc5a to your computer and use it in GitHub Desktop.
Bash script to generate an edge-Rails app.
#!/bin/sh
#
# Generates an edge-Rails application.
if [ $# -eq 0 ]
then
echo "usage: rails_edge <name>"
exit 1
fi
name=$1
mkdir $name
cd $name
# Create a Gemfile that tells bundler to install
# the `rails` gem from the GitHub source.
rails_gem="gem 'rails', github: 'rails/rails'"
cat > Gemfile << EOF
source 'https://rubygems.org'
ruby '3.0.2'
$rails_gem
EOF
bundle install
# Generate a new Rails app in the current directory using the
# latest development version (--dev).
bundle exec rails new . --dev --force
# Update the Gemfile so the `rails` dependency points at GitHub
# again rather than the local filesystem.
escaped_rails_gem=$(printf '%s\n' "$rails_gem" | sed -e 's/[\/&]/\\&/g')
sed -i '' -e 's/.*gem "rails".*/'"$escaped_rails_gem"'/g' Gemfile
bundle install
bundle exec rails s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment