Created
November 2, 2021 21:47
-
-
Save clarkware/3ff0592dd922d4b7e1275e4afd51cc5a to your computer and use it in GitHub Desktop.
Bash script to generate an edge-Rails app.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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