This app was developed using Ruby on Rails + Hotwire + Turbo + Stimulus. There are many areas to improve in this code, but I wanted to demonstrate how I leveraged Hotwire + Turbo Streams and Stimulus to build a real-time validation in the frontend.
I understand that there are side effects and possible issues with this exact approach, like ending up with multiple requests being sent to the server, and an excessive amount of requests can be an issue.
GitHub actions are in place with linter, builds, and specs so we can get a proper CI/CD pipeline ready for production.
- Modern Rails Sample App
- ruby
- postgresql
- node
Note: Before installing all the dependencies locally, check the Services section.
git clone [email protected]:lelogrott/modern-rails-sample-app.git
cd modern-rails-sample-app
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Also: https://stackoverflow.com/questions/10940736/rbenv-not-changing-ruby-version
# OS X.
brew install rbenv ruby-build
# Debian, Ubuntu, and derivatives.
sudo apt install rbenv
rbenv init # Follow the printed instructions
rbenv install $(cat .ruby-version)
# You may need to restart your shell before running this command.
# Verify ruby --version is properly sourcing the newly installed
# ruby from rbenv before running this command.
gem install bundler
Find more details about installing and updating NVM @ https://github.com/nvm-sh/nvm#installing-and-updating. Check package.json
for our node version, then copy that version into ~/.nvmrc
.
# Install NVM by running the following command, or check NVM
# documentation to see how to install its latest version.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
You may have to add the following to the correct profile file (probably ~/.zprofile if you're on macOS Catalina or later) and restart your terminal session:
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
nvm install "$(cat .nvmrc)"
nvm use
corepack enable
- Create an SSH Key
- Add it to GitHub
- Add identity to git
git config --global user.name "<your_full_name>"
git config --global user.email "<your_email>"
If you are running service dependencies via docker, install libpq via brew for the
pg
rubygem to compile successfully.
# OS X.
brew install libpq
# Debian, Ubuntu, and derivatives.
sudo apt install libpq-dev
# Intel Macs:
bundle config --local build.pg --with-opt-dir="/usr/local/opt/libpq"
# Apple Silicon Macs:
bundle config --local build.pg --with-opt-dir="/opt/homebrew/opt/libpq"
Run the following commands:
bundle install # Installs gems, including Rails
yarn install # Install JS dependencies
rbenv rehash # Make newly installed gems available from command-line
rails console # and then `exit`
# Creates DB
rails db:create
# Sets up DB, can take a while
rails db:schema:load
# start the server with nodemon
./bin/dev
When server is up, you should be able to access the following URL's:
Status URL
Users URL
That should do it. If you encounter any problems, ask another engineer for help and update the steps so that the next person doesn't run into the same issue ๐
try running this command after you have installed xcode sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
No such file or directory @ rb_sysopen - tmp/pids/server.pid (Errno::ENOENT)
If Puma crashes within the message above, just create the folder /tmp/pids
manually and it should work.