Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

323: upgrade to rails 5.1 #324

Merged
merged 12 commits into from
Nov 13, 2022
Merged

323: upgrade to rails 5.1 #324

merged 12 commits into from
Nov 13, 2022

Conversation

mikevallano
Copy link
Owner

@mikevallano mikevallano commented Nov 12, 2022

Related Issues & PRs

Closes #323

Problems Solved

  • Upgrade to Rails 5.1 as a way to keep things updated

Screenshots

5-1-in-production

Things Learned

  • Rails has a rails app:update command. Run it and hold on to your butts

@mikevallano mikevallano temporarily deployed to rocky-headland-81947 November 12, 2022 22:09 Inactive
@mikevallano mikevallano temporarily deployed to rocky-headland-81947 November 12, 2022 22:16 Inactive
@mikevallano mikevallano temporarily deployed to rocky-headland-81947 November 13, 2022 14:25 Inactive
sign_in resource_name, resource, bypass: true
bypass_sign_in(resource)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was because of devise deprecation warning

<%= devise_error_messages! %>
<%= render "devise/shared/error_messages", resource: resource %>
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolve devise deprecation warning

Comment on lines +1 to +9
# monkey patch for the json gem to fix ruby keyword arg deprecation
# https://github.com/flori/json/issues/399
module JSON
module_function

def parse(source, opts = {})
Parser.new(source, **opts).parse
end
end
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this to fix ruby deprecation warning. The code is in the gem. See ruby/json#399

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah. interesting.

@mikevallano mikevallano temporarily deployed to rocky-headland-81947 November 13, 2022 15:12 Inactive
@mikevallano mikevallano self-assigned this Nov 13, 2022
@mikevallano mikevallano requested a review from lortza November 13, 2022 15:14
Comment on lines +2 to +3
prepend_before_action :require_no_authentication, only: [:new, :create, :cancel]
prepend_before_action :authenticate_scope!, only: [:edit, :update, :destroy]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know what the difference between a before_action and a prepend_before_action was, so I looked it up.

A prepend_before_action runs before a before_action. There are no before_actions in this controller, so it seems like these prepends could just be regular before_actions. 🤔

Since we're dealing with Devise stuff, and I am not sure of the order of loading or any including that may be happening between controllers, I feel hesitant to make that change. Of course, if the Devise docs say this is the way, then this is the way. I'll do a deeper dive on that in a bit. I've got 80 more files to investigate...

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -17,6 +17,8 @@

module TmdbMoviequeue
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awwww yeah!

Comment on lines -34 to -35
# Randomize the order test cases are executed.
config.active_support.test_order = :random
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify what we just talked about, this setting is being removed here because this is the new default behavior. There will be no change in behavior by removing this line.

# Rails.application.config.assets.paths << Emoji.images_path
# Add Yarn node_modules folder to the asset load path.
Rails.application.config.assets.paths << Rails.root.join('node_modules')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol. node_modules.

# Read the Guide for Upgrading Ruby on Rails for more info on each option.

# Make `form_with` generate non-remote forms.
Rails.application.config.action_view.form_with_generates_remote_forms = false
Copy link
Collaborator

@lortza lortza Nov 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you plan to keep this setting, we need to move it into a config file. This config/initializers/new_framework_defaults_5_1.rb is a temporary file for use to help us turn on/off new settings for a slow upgrade rollout. We should plan to delete this file soon. This post has a little bit of insight https://lilyreile.medium.com/rails-5-1-new-framework-defaults-what-they-do-and-how-to-safely-uncomment-them-93921a2a5ec2

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for insights. I had no idea! After reading up on it, it looks like it only impacts form_with (which we're not currently using) and not form_for.

If we get to a point where we add a new form, surely we'll check to see what it's doing and can address it then?

So I think this can just be skipped.

The only other line in this file is commented out, so I think I'll just remove this whole file?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! Sounds good to me.

@@ -11,7 +11,7 @@ def request(endpoint, params)
return { results: [] } if params[:query].present? && searchable_query(params[:query]).empty?

api_path = build_url(endpoint, params)
response = open("#{BASE_URL}#{api_path}").read
response = URI.open("#{BASE_URL}#{api_path}").read
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How in the heck did this even work before?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤷 Based on the deprecation warning, I think it was still calling open on URI

Copy link
Collaborator

@lortza lortza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are just a few comments I have left that I'd like to chat about with you. Otherwise, it looks really good!

@mikevallano mikevallano merged commit a6f2ac4 into master Nov 13, 2022
@mikevallano mikevallano deleted the 323-upgrade-to-rails-5.1 branch November 13, 2022 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade to rails 5.1
2 participants