Skip to content

Commit

Permalink
Upgrade Example App to Rails 7 and Ruby 3.2.2
Browse files Browse the repository at this point in the history
This upgrades the example application from Rails 3.2 to Rails 7 and Ruby
3.2.2.

Over the last 3 weeks I've been joined by developers from across
thoughtbot to live stream us working on this upgrade together. You can
watch the series at
https://www.youtube.com/watch?v=gQIYXc8y-UM&list=PL8tzorAO7s0huVF53GLeKbqNmMbwJ5JGF

As we made necessary changes we attempted to minimize changes to the
text of the book, but there were a few necessary changes, which are
included along here in addition to the example app upgrade.
  • Loading branch information
sej3506 authored and cpytel committed Oct 18, 2023
1 parent 2f0f752 commit 28141fd
Show file tree
Hide file tree
Showing 83 changed files with 1,025 additions and 603 deletions.
2 changes: 1 addition & 1 deletion book/code_smells/duplicated_code.md
Expand Up @@ -37,7 +37,7 @@ def update
question_params = params.
require(:question).
permit(:title, :options_attributes, :minimum, :maximum)
@question.update_attributes(question_params)
@question.update(question_params)

if @question.save
redirect_to @question.survey
Expand Down
4 changes: 4 additions & 0 deletions book/solutions/extract_validator.md
Expand Up @@ -58,6 +58,10 @@ is validated against it.

` app/validators/enumerable_validator.rb@21f7a57

Please note that in the latest version of the example application the
`EmailValidator` class was renamed to `EmailAddressValidator` to avoid a naming
conflict with an external gem.

### Next Steps

* Verify the extracted validator does not have any [long methods](#long-methods).
Expand Down
2 changes: 1 addition & 1 deletion book/solutions/replace_conditional_with_polymorphism.md
Expand Up @@ -153,7 +153,7 @@ to the appropriate class. First, let's move the method
class MultipleChoiceQuestion < Question
def summary
total = answers.count
counts = answers.group(:text).order('COUNT(*) DESC').count
counts = answers.group(:text).order(Arel.sql('COUNT(*) DESC')).count
percents = counts.map do |text, count|
percent = (100.0 * count / total).round
"#{percent}% #{text}"
Expand Down
Empty file added example_app/.gitignore
Empty file.
1 change: 0 additions & 1 deletion example_app/.ruby-version

This file was deleted.

1 change: 1 addition & 0 deletions example_app/.tool-versions
@@ -0,0 +1 @@
ruby 3.2.2
24 changes: 12 additions & 12 deletions example_app/Gemfile
@@ -1,29 +1,29 @@
source 'https://rubygems.org'

gem 'rails', '3.2.8'
ruby '3.2.2'

gem 'rails', '7.0.8'

gem 'clearance'
gem 'jquery-rails'
gem 'simple_form'
gem 'strong_parameters'
gem 'sqlite3'
gem 'thin'

group :assets do
gem 'coffee-rails', '~> 3.2'
gem 'sass-rails', '~> 3.2'
gem 'uglifier', '>= 1.0'
end
gem 'sprockets-rails'
gem 'puma'
gem 'importmap-rails'
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]
gem 'bootsnap', require: false

group :development, :test do
gem 'bourne'
gem 'bourne', '1.3.0'
gem 'foreman'
gem 'rspec-rails'
gem 'rails-dom-testing'
gem 'listen'
end

group :test do
gem 'capybara'
gem 'email_spec'
gem 'factory_girl_rails'
gem 'factory_bot_rails'
gem 'shoulda-matchers'
end

0 comments on commit 28141fd

Please sign in to comment.