Clean up templates from a fresh Can't initialize a new Rails application within the directory of another, please change to a non-Rails directory first.

Type 'rails' for help.
This commit is contained in:
Ryan W
2023-09-30 10:32:08 -07:00
parent f13cceabf4
commit 1d8c3828a3
13 changed files with 92 additions and 109 deletions
+7 -9
View File
@@ -21,10 +21,10 @@ gem "puma", "~> 6.3"
# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails] # Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
gem "importmap-rails" gem "importmap-rails"
# Hotwire"s SPA-like page accelerator [https://turbo.hotwired.dev] # Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
gem "turbo-rails" gem "turbo-rails"
# Hotwire"s modest JavaScript framework [https://stimulus.hotwired.dev] # Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
gem "stimulus-rails" gem "stimulus-rails"
# Build JSON APIs with ease [https://github.com/rails/jbuilder] # Build JSON APIs with ease [https://github.com/rails/jbuilder]
@@ -40,16 +40,13 @@ gem "redis", "~> 5.0"
# gem "bcrypt", "~> 3.1.7" # gem "bcrypt", "~> 3.1.7"
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: %i[mingw mswin x64_mingw jruby] gem "tzinfo-data", platforms: %i[ windows jruby ]
# Reduces boot times through caching; required in config/boot.rb # Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", require: false gem "bootsnap", require: false
# Use Sass to process CSS
# gem "sassc-rails", "~> 2.1"
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
gem "image_processing", "~> 1.12" gem "image_processing", "~> 1.2"
gem "brakeman" gem "brakeman"
gem "bundler-audit" gem "bundler-audit"
@@ -57,7 +54,7 @@ gem "rubocop-rails"
group :development, :test do group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "debug", "1.8.0", platforms: %i[ mri mingw x64_mingw ] gem "debug", platforms: %i[ mri windows ]
gem "rspec-rails" gem "rspec-rails"
gem "rubocop-rspec" gem "rubocop-rspec"
end end
@@ -71,11 +68,12 @@ group :development do
# Speed up commands on slow machines / big apps [https://github.com/rails/spring] # Speed up commands on slow machines / big apps [https://github.com/rails/spring]
# gem "spring" # gem "spring"
gem "error_highlight", ">= 0.4.0", platforms: [:ruby]
end end
group :test do group :test do
# Use system testing [https://guides.rubyonrails.org/testing.html#system-testing] # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
gem "capybara" gem "capybara"
gem "selenium-webdriver" gem "selenium-webdriver"
gem "webdrivers"
end end
+5 -13
View File
@@ -106,6 +106,7 @@ GEM
diff-lcs (1.5.0) diff-lcs (1.5.0)
drb (2.1.1) drb (2.1.1)
ruby2_keywords ruby2_keywords
error_highlight (0.5.1)
erubi (1.12.0) erubi (1.12.0)
ffi (1.16.2) ffi (1.16.2)
globalid (1.2.1) globalid (1.2.1)
@@ -156,8 +157,6 @@ GEM
racc (~> 1.4) racc (~> 1.4)
nokogiri (1.15.4-arm64-darwin) nokogiri (1.15.4-arm64-darwin)
racc (~> 1.4) racc (~> 1.4)
nokogiri (1.15.4-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.15.4-x86_64-linux) nokogiri (1.15.4-x86_64-linux)
racc (~> 1.4) racc (~> 1.4)
parallel (1.23.0) parallel (1.23.0)
@@ -298,10 +297,6 @@ GEM
activemodel (>= 6.0.0) activemodel (>= 6.0.0)
bindex (>= 0.4.0) bindex (>= 0.4.0)
railties (>= 6.0.0) railties (>= 6.0.0)
webdrivers (5.2.0)
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
selenium-webdriver (~> 4.0)
webrick (1.8.1) webrick (1.8.1)
websocket (1.2.10) websocket (1.2.10)
websocket-driver (0.7.6) websocket-driver (0.7.6)
@@ -313,10 +308,7 @@ GEM
PLATFORMS PLATFORMS
aarch64-linux aarch64-linux
arm64-darwin-20
arm64-darwin-21
arm64-darwin-22 arm64-darwin-22
x86_64-darwin-22
x86_64-linux x86_64-linux
DEPENDENCIES DEPENDENCIES
@@ -324,8 +316,9 @@ DEPENDENCIES
brakeman brakeman
bundler-audit bundler-audit
capybara capybara
debug (= 1.8.0) debug
image_processing (~> 1.12) error_highlight (>= 0.4.0)
image_processing (~> 1.2)
importmap-rails importmap-rails
jbuilder jbuilder
pg (~> 1.5) pg (~> 1.5)
@@ -342,10 +335,9 @@ DEPENDENCIES
turbo-rails turbo-rails
tzinfo-data tzinfo-data
web-console web-console
webdrivers
RUBY VERSION RUBY VERSION
ruby 3.2.2p53 ruby 3.2.2p53
BUNDLED WITH BUNDLED WITH
2.4.19 2.4.20
+1 -1
View File
@@ -3,6 +3,6 @@
# Add your own tasks in files placed in lib/tasks ending in .rake, # Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require_relative 'config/application' require_relative "config/application"
Rails.application.load_tasks Rails.application.load_tasks
+2 -2
View File
@@ -1,6 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
class ApplicationMailer < ActionMailer::Base class ApplicationMailer < ActionMailer::Base
default from: 'from@example.com' default from: "from@example.com"
layout 'mailer' layout "mailer"
end end
+1 -1
View File
@@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style> <style>
/* Email styles need to be inline */ /* Email styles need to be inline */
</style> </style>
+27 -36
View File
@@ -8,46 +8,46 @@
# this file is here to facilitate running it. # this file is here to facilitate running it.
# #
require 'rubygems' require "rubygems"
m = Module.new do m = Module.new do
module_function module_function
def invoked_as_script? def invoked_as_script?
File.expand_path($PROGRAM_NAME) == File.expand_path(__FILE__) File.expand_path($0) == File.expand_path(__FILE__)
end end
def env_var_version def env_var_version
ENV['BUNDLER_VERSION'] ENV["BUNDLER_VERSION"]
end end
def cli_arg_version def cli_arg_version
return unless invoked_as_script? # don't want to hijack other binstubs return unless invoked_as_script? # don't want to hijack other binstubs
return unless 'update'.start_with?(ARGV.first || ' ') # must be running `bundle update` return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
bundler_version = nil bundler_version = nil
update_index = nil update_index = nil
ARGV.each_with_index do |a, i| ARGV.each_with_index do |a, i|
bundler_version = a if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
bundler_version = a
end
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/ next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
bundler_version = $1
bundler_version = Regexp.last_match(1)
update_index = i update_index = i
end end
bundler_version bundler_version
end end
def gemfile def gemfile
gemfile = ENV['BUNDLE_GEMFILE'] gemfile = ENV["BUNDLE_GEMFILE"]
return gemfile if gemfile && !gemfile.empty? return gemfile if gemfile && !gemfile.empty?
File.expand_path('../Gemfile', __dir__) File.expand_path("../Gemfile", __dir__)
end end
def lockfile def lockfile
lockfile = lockfile =
case File.basename(gemfile) case File.basename(gemfile)
when 'gems.rb' then gemfile.sub(/\.rb$/, gemfile) when "gems.rb" then gemfile.sub(/\.rb$/, ".locked")
else "#{gemfile}.lock" else "#{gemfile}.lock"
end end
File.expand_path(lockfile) File.expand_path(lockfile)
@@ -55,52 +55,41 @@ m = Module.new do
def lockfile_version def lockfile_version
return unless File.file?(lockfile) return unless File.file?(lockfile)
lockfile_contents = File.read(lockfile) lockfile_contents = File.read(lockfile)
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/ return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
Regexp.last_match(1) Regexp.last_match(1)
end end
def bundler_version def bundler_requirement
@bundler_version ||= @bundler_requirement ||=
env_var_version || cli_arg_version || env_var_version ||
lockfile_version cli_arg_version ||
bundler_requirement_for(lockfile_version)
end end
def bundler_requirement def bundler_requirement_for(version)
return "#{Gem::Requirement.default}.a" unless bundler_version return "#{Gem::Requirement.default}.a" unless version
bundler_gem_version = Gem::Version.new(bundler_version) bundler_gem_version = Gem::Version.new(version)
requirement = bundler_gem_version.approximate_recommendation bundler_gem_version.approximate_recommendation
return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new('2.7.0')
requirement += '.a' if bundler_gem_version.prerelease?
requirement
end end
def load_bundler! def load_bundler!
ENV['BUNDLE_GEMFILE'] ||= gemfile ENV["BUNDLE_GEMFILE"] ||= gemfile
activate_bundler activate_bundler
end end
def activate_bundler def activate_bundler
gem_error = activation_error_handling do gem_error = activation_error_handling do
gem 'bundler', bundler_requirement gem "bundler", bundler_requirement
end end
return if gem_error.nil? return if gem_error.nil?
require_error = activation_error_handling do require_error = activation_error_handling do
require 'bundler/version' require "bundler/version"
end end
if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION)) return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
return
end
warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`" warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
exit 42 exit 42
end end
@@ -115,4 +104,6 @@ end
m.load_bundler! m.load_bundler!
load Gem.bin_path('bundler', 'bundle') if m.invoked_as_script? if m.invoked_as_script?
load Gem.bin_path("bundler", "bundle")
end
+8
View File
@@ -0,0 +1,8 @@
#!/bin/bash -e
# If running the rails server then create or migrate existing database
if [ "${*}" == "./bin/rails server" ]; then
./bin/rails db:prepare
fi
exec "${@}"
+1 -1
View File
@@ -2,7 +2,7 @@
# This file is used by Rack-based servers to start the application. # This file is used by Rack-based servers to start the application.
require_relative 'config/environment' require_relative "config/environment"
run Rails.application run Rails.application
Rails.application.load_server Rails.application.load_server
-2
View File
@@ -4,8 +4,6 @@
# gem install pg # gem install pg
# On macOS with Homebrew: # On macOS with Homebrew:
# gem install pg -- --with-pg-config=/usr/local/bin/pg_config # gem install pg -- --with-pg-config=/usr/local/bin/pg_config
# On macOS with MacPorts:
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
# On Windows: # On Windows:
# gem install pg # gem install pg
# Choose the win32 build. # Choose the win32 build.
+11 -13
View File
@@ -1,6 +1,6 @@
# Files in the config/locales directory are used for internationalization # Files in the config/locales directory are used for internationalization and
# and are automatically loaded by Rails. If you want to use locales other # are automatically loaded by Rails. If you want to use locales other than
# than English, add the necessary files in this directory. # English, add the necessary files in this directory.
# #
# To use the locales, use `I18n.t`: # To use the locales, use `I18n.t`:
# #
@@ -16,18 +16,16 @@
# #
# This would use the information in config/locales/es.yml. # This would use the information in config/locales/es.yml.
# #
# The following keys must be escaped otherwise they will not be retrieved by # To learn more about the API, please read the Rails Internationalization guide
# the default I18n backend: # at https://guides.rubyonrails.org/i18n.html.
# #
# true, false, on, off, yes, no # Be aware that YAML interprets the following case-insensitive strings as
# booleans: `true`, `false`, `on`, `off`, `yes`, `no`. Therefore, these strings
# must be quoted to be interpreted as strings. For example:
# #
# Instead, surround them with single quotes. # en:
# # "yes": yup
# en: # enabled: "ON"
# "true": "foo"
#
# To learn more, please read the Rails Internationalization guide
# available at https://guides.rubyonrails.org/i18n.html.
en: en:
hello: "Hello world" hello: "Hello world"
+17 -25
View File
@@ -1,45 +1,37 @@
# frozen_string_literal: true # frozen_string_literal: true
# This configuration file will be evaluated by Puma. The top-level methods that
# are invoked here are part of Puma's configuration DSL. For more information
# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html.
# Puma can serve each request in a thread from an internal thread pool. # Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers: a minimum and maximum. # The `threads` method setting takes two numbers: a minimum and maximum.
# Any libraries that use thread pools should be configured to match # Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum # the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record. # and maximum; this matches the default thread size of Active Record.
# max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
max_threads_count = ENV.fetch('RAILS_MAX_THREADS', 5) min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
min_threads_count = ENV.fetch('RAILS_MIN_THREADS') { max_threads_count }
threads min_threads_count, max_threads_count threads min_threads_count, max_threads_count
# Specifies that the worker count should equal the number of processors in production.
if ENV["RAILS_ENV"] == "production"
require "concurrent-ruby"
worker_count = Integer(ENV.fetch("WEB_CONCURRENCY") { Concurrent.physical_processor_count })
workers worker_count if worker_count > 1
end
# Specifies the `worker_timeout` threshold that Puma will use to wait before # Specifies the `worker_timeout` threshold that Puma will use to wait before
# terminating a worker in development environments. # terminating a worker in development environments.
# worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
worker_timeout 3600 if ENV.fetch('RAILS_ENV', 'development') == 'development'
# Specifies the `port` that Puma will listen on to receive requests; default is 3000. # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
# port ENV.fetch("PORT") { 3000 }
port ENV.fetch('PORT', 3000)
# Specifies the `environment` that Puma will run in. # Specifies the `environment` that Puma will run in.
# environment ENV.fetch("RAILS_ENV") { "development" }
environment ENV.fetch('RAILS_ENV', 'development')
# Specifies the `pidfile` that Puma will use. # Specifies the `pidfile` that Puma will use.
pidfile ENV.fetch('PIDFILE', 'tmp/pids/server.pid') pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked web server processes. If using threads and workers together
# the concurrency of the application would be max `threads` * `workers`.
# Workers do not work on JRuby or Windows (both of which do not support
# processes).
#
workers ENV.fetch("WEB_CONCURRENCY") { 4 }
# Use the `preload_app!` method when specifying a `workers` number.
# This directive tells Puma to first boot the application and load code
# before forking the application. This takes advantage of Copy On Write
# process behavior so workers use less memory.
#
preload_app!
# Allow puma to be restarted by `bin/rails restart` command. # Allow puma to be restarted by `bin/rails restart` command.
plugin :tmp_restart plugin :tmp_restart
+6 -2
View File
@@ -1,11 +1,15 @@
# frozen_string_literal: true # frozen_string_literal: true
Rails.application.routes.draw do Rails.application.routes.draw do
get 'welcome/index' get "welcome/index"
# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
# Can be used by load balancers and uptime monitors to verify that the app is live.
get "up" => "rails/health#show", as: :rails_health_check
resources :articles do resources :articles do
resources :comments resources :comments
end end
root 'welcome#index' root "welcome#index"
end end
+6 -4
View File
@@ -1,8 +1,10 @@
# frozen_string_literal: true # frozen_string_literal: true
# This file should contain all the record creation needed to seed the database with its default values. # This file should ensure the existence of records required to run the application in every environment (production,
# development, test). The code here should be idempotent so that it can be executed at any point in every environment.
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup). # The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
# #
# Examples: # Example:
# #
# movies = Movie.create([{ name: "Star Wars" }, { name: "Lord of the Rings" }]) # ["Action", "Comedy", "Drama", "Horror"].each do |genre_name|
# Character.create(name: "Luke", movie: movies.first) # MovieGenre.find_or_create_by!(name: genre_name)
# end