Skip to content

Instantly share code, notes, and snippets.

@blairanderson
Last active October 17, 2025 20:53
Show Gist options
  • Select an option

  • Save blairanderson/116030279e9fccd857c770a4ea2d6ba5 to your computer and use it in GitHub Desktop.

Select an option

Save blairanderson/116030279e9fccd857c770a4ea2d6ba5 to your computer and use it in GitHub Desktop.
new rails applications

create the app

rails new your_app_name --database=postgresql --skip-jbuilder --css=tailwind

cd into app

cd your_app_name

copy .env

cat > .env <<'EOF'
# EDITOR="nano" bin/rails credentials:edit --environment development
# EDITOR="nano" bin/rails credentials:edit --environment production
# heroku config:set RAILS_MASTER_KEY=`cat config/credentials/production.key`
# HATCHBOX config:set RAILS_MASTER_KEY=`cat config/credentials/production.key`
# OPENAI RAILS_MASTER_KEY=`cat config/credentials/development.key`
# OPENAI SECRET_KEY_BASE=`cat tmp/local_secret.txt`
ADMIN_USERNAME=admin
ADMIN_PASSWORD=admin
EOF

install javascript

mkdir frontend
touch frontend/.keep
touch package.json
cat > package.json <<'EOF'
{
  "name": "your-app",
  "type": "module",
  "private": true,
  "scripts": {
    "dev": "bun build frontend/ButtonCounter --outdir=vendor/javascript/apps --target=browser --format=esm --minify --watch",
    "build": "bun build frontend/ButtonCounter --outdir=vendor/javascript/apps --target=browser --format=esm --minify --production"
  },
  "devDependencies": {
    "@types/bun": "latest"
  },
  "peerDependencies": {
    "typescript": "^5"
  }
}
EOF

echo 'node_modules' >> .gitignore
echo '/node_modules' >> .gitignore
bun add react react-dom
echo 'bun install && bun run dev' >> Procfile.dev

add your first Bun/React component

mkdir frontend/ButtonCounter
touch frontend/ButtonCounter/index.js
cat > frontend/ButtonCounter/index.js <<'EOF'
import React from "react";
import { createRoot } from "react-dom/client";

function ButtonCounter() {
    const [count, setCount] = useState(0);
  return (
    <div>
        <button onClick={() => setCount(count + 1)}>I'm a button</button>
        <p>Count: {count}</p>
    </div>
  );
}
// Create a root element and mount the component to the DOM
const rootElement = document.createElement("div");
document.body.appendChild(rootElement);

const root = createRoot(rootElement);
root.render(<ButtonCounter />);
EOF

create github repo

  • RUN gh repo create your_app_name --private --homepage yourwebsite.com --source=.
  • RUN git remote add origin [email protected]:blairanderson/your_app_name.git

Database

bin/rails db:create db:migrate
bin/rails g authentication
bundle add "public_suffix"
bundle add "mission_control-jobs"

Email

bundle add "postmark-rails"

Development

ADD config.hosts << "app.lvh.me" to development.rb RUN rails g controller home show

Production

RUN bundle lock --add-platform x86_64-linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment