Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ gemfiles/*.lock
/.ruby-version
Vagrantfile
.vagrant
.yarnrc
**/.yarn/**/cache
**/.yarn/install-state.gz
**/.yarn/unplugged

# For the demo app.

Expand All @@ -25,7 +27,7 @@ demo/storage/*
!demo/storage/.keep

demo/public/assets
.byebug_history
**/.byebug_history

# Ignore master key for decrypting credentials and more.
demo/config/master.key
Expand Down
5 changes: 5 additions & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


lastUpdateCheck 1681870014941
30 changes: 20 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,30 +169,40 @@ To run the demo app, set up the database and run the server:
cd demo
bundle
rails db:setup
yarn build --watch &
rails s -b 0.0.0.0
dev
```

To run the demo app in the Docker container:

```bash
docker run --volume "$PWD:/app" --user $UID:`grep ^$USERNAME /etc/passwd | cut -d: -f4` -p 3000:3000 -it bootstrap_form /bin/bash
cd demo
export BUNDLE_GEMFILE=../gemfiles/7.0.gemfile
bundle
rails db:setup
yarn build --watch &
rails s -b 0.0.0.0
dev
```

The app doesn't appear to find the source map, or perhaps it isn't being generated. In the Rails log you will see messages similar to:
You'll see errors in the browser console about duplicate ids. This is expected, since the demo app has many forms with the same fields in them. Something we can fix in the future, perhaps.

```bash
ActionController::RoutingError (No route matches [GET] "/assets/application.js-c6c0edbd68f05cffd0e2495198bfbc4bf42be8a11b76eecbfade30a8036b6b87.map")
To use other supported versions of Rails, you will need to create a `Gemfile` for the Rails version. Then, change the `export BUNDLE_GEMFILE...` line to your gem file. Finally, figure out how to include the assets.

If you need to run the Rails server separately, for example, to debug the server, you _must_ run it like this:

```sh
bundle exec rails s -b 0.0.0.0
```

But this doesn't seem to affect how the app runs.
If you run just `rails` or even `bin/rails`, the `sprockets-rails` gem won't load and you'll either get error messages, or the assets won't be available to the demo app. At the moment it's a mystery why. PRs to fix this are welcome.

To use other supported versions of Rails, you will need to create a `Gemfile` for the Rails version. Then, change the `export BUNDLE_GEMFILE...` line to your gem file. Finally, figure out how to include the assets.
Please try to keep the checked-in `.ruby-version` set to the oldest supported version of Ruby. You're welcome and encouraged to try the demo app with other Ruby versions. Just don't check in the `.ruby-version` to GitHub.

For the record, the demo app is set up as if the Rails app had been created with:

```sh
rails new --skip-hotwire -d sqlite --edge -j esbuild -c bootstrap .
```

This means it's using `esbuild` to pre-process the JavaScript and (S)CSS, and that it's using [`jsbunding-rails`](https://github.com/rails/jsbundling-rails) and [`cssbundling-rails`](https://github.com/rails/cssbundling-rails) to put the assets in `app/assets/builds`, before the Sprockets assets pipeline serves them in development, or pre-compiles them in production.

## Documentation Contributions

Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ ENV PATH ./bin:$GEM_HOME/bin:$PATH
RUN (echo 'docker'; echo 'docker') | passwd root

# Yarn installs nodejs.
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt update -y -q && \
apt install -y -q yarn sqlite3
# Rails wants a newer version of node that we get with the Debian distro.
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && apt-get install -y nodejs
RUN corepack enable && corepack prepare yarn@stable --activate
RUN apt install -y -q yarn sqlite3

EXPOSE 3000
2 changes: 1 addition & 1 deletion demo/.ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby-2.7.6
ruby-3.0.5
3 changes: 3 additions & 0 deletions demo/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
enableTelemetry: 0

nodeLinker: node-modules
16 changes: 4 additions & 12 deletions demo/Gemfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby File.read("#{__dir__}/.ruby-version").delete_prefix("ruby-").chomp

# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.0.0"

# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
gem "sprockets-rails"
gem "sprockets-rails", require: "sprockets/railtie"

# Use sqlite3 as the database for Active Record
gem "sqlite3", "~> 1.4"
Expand All @@ -18,12 +16,6 @@ gem "puma", "~> 5.0"
# Bundle and transpile JavaScript [https://github.com/rails/jsbundling-rails]
gem "jsbundling-rails"

# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
gem "turbo-rails"

# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
gem "stimulus-rails"

# Bundle and process CSS [https://github.com/rails/cssbundling-rails]
gem "cssbundling-rails"

Expand All @@ -45,20 +37,20 @@ gem "tzinfo-data", platforms: %i[mingw mswin x64_mingw jruby]
# Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", require: false

gem "bootstrap_form", "~> 5.0"
gem "bootstrap_form", path: ".."

# Needed for our demo app but not the gem itself
gem "htmlbeautifier"

# Use Sass to process CSS
gem "sassc-rails"
# gem "sassc-rails"

# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
# gem "image_processing", "~> 1.2"

group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
# gem "debug", platforms: %i[mri mingw x64_mingw]
gem "debug", platforms: %i[mri mingw x64_mingw]
end

group :development do
Expand Down
Loading