diff --git a/.controlplane/Dockerfile b/.controlplane/Dockerfile index ba6a97b1..3e9f83f6 100644 --- a/.controlplane/Dockerfile +++ b/.controlplane/Dockerfile @@ -3,7 +3,7 @@ FROM ruby:3.1.2 RUN apt-get update # install node and yarn -RUN curl -sL https://deb.nodesource.com/setup_16.x | bash +RUN curl -sL https://deb.nodesource.com/setup_18.x | bash RUN apt-get install -y nodejs RUN npm install -g yarn diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d08df6c4..12eedca1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -50,13 +50,12 @@ jobs: - name: Install Ruby and gems uses: ruby/setup-ruby@0a29871fe2b0200a17a4497bae54fe5df0d973aa # v1.115.3 with: - ruby: 3.x bundler-cache: true - - name: Use Node.js 16.x + - name: Use Node.js 18.x uses: actions/setup-node@v3 with: - node-version: 16.x + node-version: 18.x - name: Install Node Packages run: npm install --legacy-peer-deps diff --git a/.nvmrc b/.nvmrc index 832d3850..0e9dc6b5 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -16.14.0 +v18.13.0 diff --git a/.rubocop.yml b/.rubocop.yml index 4fbd5a12..8c6368e1 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -67,6 +67,7 @@ Metrics/ClassLength: Metrics/BlockLength: Exclude: + - 'config/environments/development.rb' - 'lib/tasks/linters.rake' - 'spec/rails_helper.rb' - 'spec/system/add_new_comment_spec.rb' diff --git a/Dockerfile b/Dockerfile index b39eea76..47853530 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ FROM ruby:3.1.2 RUN apt-get update -RUN curl -sL https://deb.nodesource.com/setup_16.x | bash +RUN curl -sL https://deb.nodesource.com/setup_18.x | bash RUN apt-get install -y nodejs RUN npm install -g yarn @@ -14,14 +14,14 @@ COPY Gemfile* ./ RUN bundle install -COPY package.json yarn.lock . +COPY package.json yarn.lock ./ RUN yarn install -COPY . . - -RUN rails react_on_rails:locale && RAILS_ENV=production rails assets:precompile +COPY . ./ ENV RAILS_ENV=production ENV NODE_ENV=production +RUN rails react_on_rails:locale && rails assets:precompile + CMD ["rails", "s"] diff --git a/Gemfile b/Gemfile index b696123c..da7cf969 100644 --- a/Gemfile +++ b/Gemfile @@ -10,7 +10,7 @@ gem "shakapacker", "6.5.5" # Bundle edge Rails instead: gem "rails", github: "rails/rails" gem "listen" -gem "rails", "~> 6.1.4" +gem "rails", "~> 7.0" gem "pg" @@ -82,6 +82,8 @@ group :development, :test do ################################################################################ # Favorite debugging gems + gem "debug", ">= 1.0.0" + gem "pry" gem "pry-byebug" gem "pry-doc" @@ -102,7 +104,7 @@ group :test do gem "generator_spec" gem "launchy" gem "rails_best_practices" - gem "rspec-rails" - gem "selenium-webdriver" - gem "webdrivers", "3.9.4" + gem "rspec-rails", "~> 6.0.0" + gem "selenium-webdriver", "~> 4" + gem "webdrivers", "~> 5.2" end diff --git a/Gemfile.lock b/Gemfile.lock index 0ed53bf9..16727f08 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,69 +1,75 @@ GEM remote: https://rubygems.org/ specs: - actioncable (6.1.4.4) - actionpack (= 6.1.4.4) - activesupport (= 6.1.4.4) + actioncable (7.0.4.1) + actionpack (= 7.0.4.1) + activesupport (= 7.0.4.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.4.4) - actionpack (= 6.1.4.4) - activejob (= 6.1.4.4) - activerecord (= 6.1.4.4) - activestorage (= 6.1.4.4) - activesupport (= 6.1.4.4) + actionmailbox (7.0.4.1) + actionpack (= 7.0.4.1) + activejob (= 7.0.4.1) + activerecord (= 7.0.4.1) + activestorage (= 7.0.4.1) + activesupport (= 7.0.4.1) mail (>= 2.7.1) - actionmailer (6.1.4.4) - actionpack (= 6.1.4.4) - actionview (= 6.1.4.4) - activejob (= 6.1.4.4) - activesupport (= 6.1.4.4) + net-imap + net-pop + net-smtp + actionmailer (7.0.4.1) + actionpack (= 7.0.4.1) + actionview (= 7.0.4.1) + activejob (= 7.0.4.1) + activesupport (= 7.0.4.1) mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp rails-dom-testing (~> 2.0) - actionpack (6.1.4.4) - actionview (= 6.1.4.4) - activesupport (= 6.1.4.4) - rack (~> 2.0, >= 2.0.9) + actionpack (7.0.4.1) + actionview (= 7.0.4.1) + activesupport (= 7.0.4.1) + rack (~> 2.0, >= 2.2.0) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.4.4) - actionpack (= 6.1.4.4) - activerecord (= 6.1.4.4) - activestorage (= 6.1.4.4) - activesupport (= 6.1.4.4) + actiontext (7.0.4.1) + actionpack (= 7.0.4.1) + activerecord (= 7.0.4.1) + activestorage (= 7.0.4.1) + activesupport (= 7.0.4.1) + globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (6.1.4.4) - activesupport (= 6.1.4.4) + actionview (7.0.4.1) + activesupport (= 7.0.4.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.1.4.4) - activesupport (= 6.1.4.4) + activejob (7.0.4.1) + activesupport (= 7.0.4.1) globalid (>= 0.3.6) - activemodel (6.1.4.4) - activesupport (= 6.1.4.4) - activerecord (6.1.4.4) - activemodel (= 6.1.4.4) - activesupport (= 6.1.4.4) - activestorage (6.1.4.4) - actionpack (= 6.1.4.4) - activejob (= 6.1.4.4) - activerecord (= 6.1.4.4) - activesupport (= 6.1.4.4) - marcel (~> 1.0.0) + activemodel (7.0.4.1) + activesupport (= 7.0.4.1) + activerecord (7.0.4.1) + activemodel (= 7.0.4.1) + activesupport (= 7.0.4.1) + activestorage (7.0.4.1) + actionpack (= 7.0.4.1) + activejob (= 7.0.4.1) + activerecord (= 7.0.4.1) + activesupport (= 7.0.4.1) + marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (6.1.4.4) + activesupport (7.0.4.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - zeitwerk (~> 2.3) - addressable (2.8.0) - public_suffix (>= 2.0.2, < 5.0) + addressable (2.8.1) + public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) - autoprefixer-rails (10.4.0.0) + autoprefixer-rails (10.4.7.0) execjs (~> 2) awesome_print (1.9.2) bindex (0.8.1) @@ -71,7 +77,7 @@ GEM debug_inspector (>= 0.0.1) builder (3.2.4) byebug (11.1.3) - capybara (3.36.0) + capybara (3.38.0) addressable matrix mini_mime (>= 0.1.3) @@ -80,11 +86,10 @@ GEM rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) - capybara-screenshot (1.0.25) + capybara-screenshot (1.0.26) capybara (>= 1.0, < 4) launchy - childprocess (3.0.0) - code_analyzer (0.5.2) + code_analyzer (0.5.5) sexp_processor coderay (1.1.3) coffee-rails (5.0.0) @@ -94,7 +99,7 @@ GEM coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.1.9) + concurrent-ruby (1.1.10) connection_pool (2.3.0) coveralls_reborn (0.25.0) simplecov (>= 0.18.1, < 0.22.0) @@ -108,72 +113,81 @@ GEM activerecord (>= 5.a) database_cleaner-core (~> 2.0.0) database_cleaner-core (2.0.1) - date (3.3.2) + date (3.3.3) + debug (1.7.1) + irb (>= 1.5.0) + reline (>= 0.3.1) debug_inspector (1.1.0) diff-lcs (1.5.0) docile (1.4.0) - erubi (1.10.0) + erubi (1.12.0) erubis (2.7.0) execjs (2.8.1) - factory_bot (6.2.0) + factory_bot (6.2.1) activesupport (>= 5.0.0) factory_bot_rails (6.2.0) factory_bot (~> 6.2.0) railties (>= 5.0.0) - ffi (1.15.4) + ffi (1.15.5) foreman (0.87.2) generator_spec (0.9.4) activesupport (>= 3.0.0) railties (>= 3.0.0) - globalid (1.0.0) + globalid (1.0.1) activesupport (>= 5.0) - i18n (1.8.11) + i18n (1.12.0) concurrent-ruby (~> 1.0) interception (0.5) + io-console (0.6.0) + irb (1.6.2) + reline (>= 0.3.0) jbuilder (2.11.5) actionview (>= 5.0.0) activesupport (>= 5.0.0) - json (2.6.1) - launchy (2.5.0) - addressable (~> 2.7) - listen (3.7.0) + json (2.6.3) + launchy (2.5.2) + addressable (~> 2.8) + listen (3.8.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.13.0) + loofah (2.19.1) crass (~> 1.0.2) nokogiri (>= 1.5.9) - mail (2.7.1) + mail (2.8.0.1) mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp marcel (1.0.2) matrix (0.4.2) method_source (1.0.0) mini_mime (1.1.2) mini_portile2 (2.8.1) - minitest (5.15.0) - net-imap (0.3.2) + minitest (5.17.0) + net-imap (0.3.4) date net-protocol net-pop (0.1.2) net-protocol - net-protocol (0.1.3) + net-protocol (0.2.1) timeout - net-smtp (0.3.2) + net-smtp (0.3.3) net-protocol nio4r (2.5.8) - nokogiri (1.13.10) + nokogiri (1.14.0) mini_portile2 (~> 2.8.0) racc (~> 1.4) - parallel (1.21.0) - parser (3.1.1.0) + parallel (1.22.1) + parser (3.2.0.0) ast (~> 2.4.1) - pg (1.2.3) - pry (0.14.1) + pg (1.4.5) + pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) - pry-byebug (3.8.0) + pry-byebug (3.10.1) byebug (~> 11.0) - pry (~> 0.10) - pry-doc (1.2.0) + pry (>= 0.13, < 0.15) + pry-doc (1.4.0) pry (~> 0.11) yard (~> 0.9.11) pry-rails (0.3.9) @@ -184,55 +198,58 @@ GEM pry-stack_explorer (0.6.1) binding_of_caller (~> 1.0) pry (~> 0.13) - public_suffix (4.0.6) - puma (5.5.2) + psych (5.0.2) + stringio + public_suffix (5.0.1) + puma (6.0.2) nio4r (~> 2.0) racc (1.6.2) - rack (2.2.3) - rack-proxy (0.7.4) + rack (2.2.6.2) + rack-proxy (0.7.6) rack - rack-test (1.1.0) - rack (>= 1.0, < 3) - rails (6.1.4.4) - actioncable (= 6.1.4.4) - actionmailbox (= 6.1.4.4) - actionmailer (= 6.1.4.4) - actionpack (= 6.1.4.4) - actiontext (= 6.1.4.4) - actionview (= 6.1.4.4) - activejob (= 6.1.4.4) - activemodel (= 6.1.4.4) - activerecord (= 6.1.4.4) - activestorage (= 6.1.4.4) - activesupport (= 6.1.4.4) + rack-test (2.0.2) + rack (>= 1.3) + rails (7.0.4.1) + actioncable (= 7.0.4.1) + actionmailbox (= 7.0.4.1) + actionmailer (= 7.0.4.1) + actionpack (= 7.0.4.1) + actiontext (= 7.0.4.1) + actionview (= 7.0.4.1) + activejob (= 7.0.4.1) + activemodel (= 7.0.4.1) + activerecord (= 7.0.4.1) + activestorage (= 7.0.4.1) + activesupport (= 7.0.4.1) bundler (>= 1.15.0) - railties (= 6.1.4.4) - sprockets-rails (>= 2.0.0) + railties (= 7.0.4.1) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) - rails-html-sanitizer (1.4.2) - loofah (~> 2.3) - rails_best_practices (1.22.1) + rails-html-sanitizer (1.4.4) + loofah (~> 2.19, >= 2.19.1) + rails_best_practices (1.23.2) activesupport - code_analyzer (>= 0.5.2) + code_analyzer (~> 0.5.5) erubis i18n json require_all (~> 3.0) ruby-progressbar - railties (6.1.4.4) - actionpack (= 6.1.4.4) - activesupport (= 6.1.4.4) + railties (7.0.4.1) + actionpack (= 7.0.4.1) + activesupport (= 7.0.4.1) method_source - rake (>= 0.13) + rake (>= 12.2) thor (~> 1.0) - rainbow (3.0.0) + zeitwerk (~> 2.5) + rainbow (3.1.1) rake (13.0.6) - rb-fsevent (0.11.0) + rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) - rdoc (6.3.3) + rdoc (6.5.0) + psych (>= 4.0.0) react_on_rails (13.2.0) addressable connection_pool @@ -240,26 +257,28 @@ GEM rails (>= 5.2) rainbow (~> 3.0) redis (3.3.3) - regexp_parser (2.2.0) + regexp_parser (2.6.1) + reline (0.3.2) + io-console (~> 0.5) require_all (3.0.0) rexml (3.2.5) - rspec-core (3.10.1) - rspec-support (~> 3.10.0) - rspec-expectations (3.10.1) + rspec-core (3.12.0) + rspec-support (~> 3.12.0) + rspec-expectations (3.12.2) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.10.0) - rspec-mocks (3.10.2) + rspec-support (~> 3.12.0) + rspec-mocks (3.12.3) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.10.0) - rspec-rails (5.0.2) - actionpack (>= 5.2) - activesupport (>= 5.2) - railties (>= 5.2) - rspec-core (~> 3.10) - rspec-expectations (~> 3.10) - rspec-mocks (~> 3.10) - rspec-support (~> 3.10) - rspec-support (3.10.3) + rspec-support (~> 3.12.0) + rspec-rails (6.0.1) + actionpack (>= 6.1) + activesupport (>= 6.1) + railties (>= 6.1) + rspec-core (~> 3.11) + rspec-expectations (~> 3.11) + rspec-mocks (~> 3.11) + rspec-support (~> 3.11) + rspec-support (3.12.0) rubocop (1.24.1) parallel (~> 1.10) parser (>= 3.0.0.0) @@ -269,16 +288,16 @@ GEM rubocop-ast (>= 1.15.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.16.0) + rubocop-ast (1.24.1) parser (>= 3.1.1.0) - rubocop-performance (1.13.2) + rubocop-performance (1.15.2) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) - rubocop-rails (2.13.2) + rubocop-rails (2.15.2) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.7.0, < 2.0) - rubocop-rspec (2.8.0) + rubocop-rspec (2.11.1) rubocop (~> 1.19) ruby-progressbar (1.11.0) rubyzip (1.3.0) @@ -299,13 +318,14 @@ GEM tilt scss_lint (0.59.0) sass (~> 3.5, >= 3.5.5) - sdoc (2.3.0) - rdoc (>= 5.0, < 6.4.0) - selenium-webdriver (3.142.7) - childprocess (>= 0.5, < 4.0) - rubyzip (>= 1.2.2) + sdoc (2.6.0) + rdoc (>= 5.0) + selenium-webdriver (4.7.1) + rexml (~> 3.2, >= 3.2.5) + rubyzip (>= 1.2.2, < 3.0) + websocket (~> 1.0) semantic_range (3.0.0) - sexp_processor (4.16.0) + sexp_processor (4.16.1) shakapacker (6.5.5) activesupport (>= 5.2) rack-proxy (>= 0.6.1) @@ -317,47 +337,49 @@ GEM simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) - spring (4.0.0) + spring (4.1.1) spring-commands-rspec (1.0.4) spring (>= 0.9.1) - sprockets (4.0.2) + sprockets (4.2.0) concurrent-ruby (~> 1.0) - rack (> 1, < 3) + rack (>= 2.2.4, < 4) sprockets-rails (3.4.2) actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) + stringio (3.0.4) sync (0.5.0) term-ansicolor (1.7.1) tins (~> 1.0) thor (1.2.1) - tilt (2.0.10) - timeout (0.3.0) - tins (1.31.1) + tilt (2.0.11) + timeout (0.3.1) + tins (1.32.1) sync - tzinfo (2.0.4) + tzinfo (2.0.5) concurrent-ruby (~> 1.0) uglifier (4.2.0) execjs (>= 0.3.0, < 3) - unicode-display_width (2.1.0) + unicode-display_width (2.4.2) web-console (4.2.0) actionview (>= 6.0.0) activemodel (>= 6.0.0) bindex (>= 0.4.0) railties (>= 6.0.0) - webdrivers (3.9.4) + webdrivers (5.2.0) nokogiri (~> 1.6) - rubyzip (~> 1.0) - selenium-webdriver (~> 3.0) + rubyzip (>= 1.3.0) + selenium-webdriver (~> 4.0) webrick (1.7.0) + websocket (1.2.9) websocket-driver (0.7.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - yard (0.9.27) + yard (0.9.28) webrick (~> 1.7.0) - zeitwerk (2.5.3) + zeitwerk (2.6.6) PLATFORMS ruby @@ -370,6 +392,7 @@ DEPENDENCIES coffee-rails coveralls_reborn (~> 0.25.0) database_cleaner + debug (>= 1.0.0) factory_bot_rails foreman generator_spec @@ -387,13 +410,13 @@ DEPENDENCIES pry-rescue pry-stack_explorer puma - rails (~> 6.1.4) + rails (~> 7.0) rails-html-sanitizer rails_best_practices rainbow react_on_rails (= 13.2.0) redis (= 3.3.3) - rspec-rails + rspec-rails (~> 6.0.0) rubocop (= 1.24.1) rubocop-performance (~> 1.13) rubocop-rails @@ -401,13 +424,13 @@ DEPENDENCIES sass-rails scss_lint sdoc - selenium-webdriver + selenium-webdriver (~> 4) shakapacker (= 6.5.5) spring spring-commands-rspec uglifier web-console - webdrivers (= 3.9.4) + webdrivers (~> 5.2) RUBY VERSION ruby 3.1.2p20 diff --git a/README.md b/README.md index cef1109b..b4dd75dd 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,7 @@ You can see this tutorial live here: [http://reactrails.com/](http://reactrails. - Example of React with [CSS Modules](http://glenmaddern.com/articles/css-modules) inside of Rails using Webpack as described in [Smarter CSS builds with Webpack](http://bensmithett.com/smarter-css-builds-with-webpack/). - Example of enabling hot reloading of both JS and CSS (modules) from your Rails app in development mode. Change your code. Save. Browser updates without a refresh! - Example of React/Redux with Rails Action Cable. -- Example of Rails 5 with ReactJs/Redux/React-Router with Webpack and ES7. +- Example of Rails 7 with ReactJs/Redux/React-Router with Webpack and ES7. - Enabling development of a JS client independently from Rails using the [Webpack Dev Server](https://webpack.js.org/configuration/dev-server/). You can see this by starting the app and visiting http://localhost:4000 - Enabling the use of npm modules and [Babel](https://babeljs.io/) with a Rails application using [Webpack](https://webpack.github.io/). - Easily enable retrofitting such a JS framework into an existing Rails app. You don't need a brand new single page app! @@ -130,15 +130,15 @@ See package.json and Gemfile for versions 1. [react-router-redux](https://github.com/reactjs/react-router-redux) 1. [Webpack with hot-reload](https://github.com/webpack/docs/wiki/hot-module-replacement-with-webpack) (for local dev) 1. [Babel transpiler](https://github.com/babel/babel) -1. [Ruby on Rails 5](http://rubyonrails.org/) for backend app and comparison with plain HTML -1. [Heroku for Rails 5 deployment](https://devcenter.heroku.com/articles/getting-started-with-rails5) +1. [Ruby on Rails 7](http://rubyonrails.org/) for backend app and comparison with plain HTML +1. [Heroku for Rails 7 deployment](https://devcenter.heroku.com/articles/getting-started-with-rails7) 1. [Deployment to the ControlPlane](.controlplane/readme.md) 1. [Turbolinks 5](https://github.com/turbolinks/turbolinks) ## Basic Demo Setup ### Prerequisites -- Node `v16.14.0` or above. Be sure that you have Node installed! We suggest using [nvm](https://github.com/creationix/nvm) and running `nvm list` to check the active Node version. See this article [Updating and using nvm](http://forum.shakacode.com/t/updating-and-using-nvm/293). +- Node `v18.13.0` or above. Be sure that you have Node installed! We suggest using [nvm](https://github.com/creationix/nvm) and running `nvm list` to check the active Node version. See this article [Updating and using nvm](http://forum.shakacode.com/t/updating-and-using-nvm/293). - Ruby 3.1.2 or above - Postgres v9.2 or above - Redis. Check that you have Redis installed by running `which redis-server`. If missing and on MacOS, install with Homebrew (`brew install redis`) diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 67151b0c..55ec89c7 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -28,7 +28,7 @@ def create respond_to do |format| if @comment.save - format.html { redirect_to @comment, notice: "Comment was successfully created." } + format.html { redirect_to @comment, notice: I18n.t("comment_was_successfully_created") } format.json { render :show, status: :created, location: @comment } else format.html { render :new } @@ -42,7 +42,7 @@ def create def update respond_to do |format| if @comment.update(comment_params) - format.html { redirect_to @comment, notice: "Comment was successfully updated." } + format.html { redirect_to @comment, notice: I18n.t("comment_was_successfully_updated") } format.json { render :show, status: :ok, location: @comment } else format.html { render :edit } @@ -56,7 +56,7 @@ def update def destroy @comment.destroy! respond_to do |format| - format.html { redirect_to comments_url, notice: "Comment was successfully destroyed." } + format.html { redirect_to comments_url, notice: I18n.t("comment_was_successfully_destroyed") } format.json { head :no_content } end end diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index c6b9383f..2ebf76ed 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -43,8 +43,8 @@ def set_comments end def comments_json_string - render_to_string(template: "/comments/index.json.jbuilder", - locals: { comments: Comment.all }, format: :json) + render_to_string(template: "/comments/index", + locals: { comments: Comment.all }, formats: :json) end def render_html diff --git a/bin/setup b/bin/setup index 57923026..90700ac4 100755 --- a/bin/setup +++ b/bin/setup @@ -17,6 +17,9 @@ FileUtils.chdir APP_ROOT do system! 'gem install bundler --conservative' system('bundle check') || system!('bundle install') + # Install JavaScript dependencies + system! 'bin/yarn' + # puts "\n== Copying sample files ==" # unless File.exist?('config/database.yml') # FileUtils.cp 'config/database.yml.sample', 'config/database.yml' diff --git a/config/cable.yml b/config/cable.yml index 66e463e7..e108bb59 100644 --- a/config/cable.yml +++ b/config/cable.yml @@ -1,7 +1,7 @@ production: adapter: redis url: <%#= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> - + channel_prefix: rails_react_tutorial_production development: adapter: redis diff --git a/config/environments/development.rb b/config/environments/development.rb index ac8d085d..a76b413e 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -16,6 +16,9 @@ # Show full error reports. config.consider_all_requests_local = true + # Enable server timing + config.server_timing = true + # Enable/disable caching. By default caching is disabled. # Run rails dev:cache to toggle caching. if Rails.root.join("tmp/caching-dev.txt").exist? diff --git a/config/environments/test.rb b/config/environments/test.rb index 86ff12e0..08426ee9 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -10,11 +10,13 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. + # Turn false under Spring and add config.action_view.cache_template_loading = true. config.cache_classes = true - # Do not eager load code on boot. This avoids loading your whole application - # just for the purpose of running a single test. If you are using a tool that - # preloads Rails for running tests, you may have to set it to true. + # Eager loading loads your whole application. When running a single test locally, + # this probably isn't necessary. It's a good idea to do in a continuous integration + # system, or in some way before deploying your code. + # config.eager_load = ENV["CI"].present? config.eager_load = false # Configure public file server for tests with Cache-Control for performance. diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index f7fadc06..62a49ddd 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -1,32 +1,28 @@ # frozen_string_literal: true # Be sure to restart your server when you modify this file. -# Define an application-wide content security policy -# For further information see the following documentation -# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy +# Define an application-wide content security policy. +# See the Securing Rails Applications Guide for more information: +# https://guides.rubyonrails.org/security.html#content-security-policy-header -# Rails.application.config.content_security_policy do |policy| -# # If you are using webpack-dev-server then specify webpack-dev-server host -# policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development? - -# policy.default_src :self, :https -# policy.font_src :self, :https, :data -# policy.img_src :self, :https, :data -# policy.object_src :none -# policy.script_src :self, :https -# policy.style_src :self, :https - -# # Specify URI for violation reports -# # policy.report_uri "/csp-violation-report-endpoint" +# Rails.application.configure do +# config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# # If you are using webpack-dev-server then specify webpack-dev-server host +# policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development? +# end +# +# # Generate session nonces for permitted importmap and inline scripts +# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } +# config.content_security_policy_nonce_directives = %w(script-src) +# +# # Report violations without enforcing the policy. +# # config.content_security_policy_report_only = true # end - -# If you are using UJS then enable automatic nonce generation -# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } - -# Set the nonce only to specific directives -# Rails.application.config.content_security_policy_nonce_directives = %w(script-src) - -# Report CSP violations to a specified URI -# For further information see the following documentation: -# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only -# Rails.application.config.content_security_policy_report_only = true diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index 3babc73f..3df77c5b 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -2,7 +2,9 @@ # Be sure to restart your server when you modify this file. -# Configure sensitive parameters which will be filtered from the log file. +# Configure parameters to be filtered from the log file. Use this to limit dissemination of +# sensitive information. See the ActiveSupport::ParameterFilter documentation for supported +# notations and behaviors. Rails.application.config.filter_parameters += %i[ passw secret token _key crypt salt certificate otp ssn ] diff --git a/config/initializers/new_framework_defaults_7_0.rb b/config/initializers/new_framework_defaults_7_0.rb new file mode 100644 index 00000000..5aefca51 --- /dev/null +++ b/config/initializers/new_framework_defaults_7_0.rb @@ -0,0 +1,134 @@ +# frozen_string_literal: true +# Be sure to restart your server when you modify this file. +# +# This file eases your Rails 7.0 framework defaults upgrade. +# +# Uncomment each configuration one by one to switch to the new default. +# Once your application is ready to run with all new defaults, you can remove +# this file and set the `config.load_defaults` to `7.0`. +# +# Read the Guide for Upgrading Ruby on Rails for more info on each option. +# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html + +# `button_to` view helper will render `