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

Support Rails 8.0 #152

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions app/models/scimitar/complex_types/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def initialize(options={})
# attributes of this complex type object.
#
def as_json(options={})
options = options.dup if options.frozen?
options[:except] ||= ['errors']
super.except(options)
Copy link
Member

@pond pond Nov 18, 2024

Choose a reason for hiding this comment

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

This is Rails 8 making five minute tasks take hours, again. Rails 7 and 8 have felt like the "bad old days" of Rails 2/3/4 era massive changes in APIs and constant dev churn. I can't find many references to frozen-by-default Hashes anywhere inside the higher level Rails 8 changes, yet it's a major change that (as we see here) can cause breakage.

In any case, I've just realised that this code was broken anyway. The "correct" #as_json takes some finding, but the relevant #as_json's options include except:. That's what is being manipulated on line 78.

So we now call super, without parens so it gets passed any and all parameters including our options. The result is a Hash. We're then calling Hash#except, but that takes the keys to exclude as a list/Array, yet we're providing an options Hash with who-knows-what as the keys. Besides, since the options were already passed in, exclusions already happened.

I'd like to contribute some minor changes to your branch to get things working for Rails 7/8 and have CI pass (for which I think I might be forced to concede auto-test for Ruby 3.2 or later only and drop tests for earlier versions, even though they still work perfectly). For example, this change - and there's one other place something similar isn needed, if tests are to pass - becomes, in my preferred variation after trying a few:

      def as_json(options={})
        exclusions = options[:except] || ['errors']
        super(options.merge(except: exclusions))
      end

Are you able and willing to grant me push permission for the changes, per this reference? TIA!

Copy link
Member

Choose a reason for hiding this comment

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

@terracatta ...ah, yay, it can be done for old Rubies by modifying the Rails constraint by version. It looks like this: #154

end
Expand Down
2 changes: 1 addition & 1 deletion scimitar.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Gem::Specification.new do |s|

s.required_ruby_version = '>= 2.7.0'

s.add_dependency 'rails', '~> 7.0'
s.add_dependency 'rails', '~> 8.0'
Copy link
Member

Choose a reason for hiding this comment

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

This means people MUST use Rails 8. We certainly have no intention of upgrading yet given how buggy 7.1 and 7.2 have been for us - it feels like the Rails team is rushing and it's been a very small time between Rails 7 and 8. so we're being very cautious.

I think you want something like >= 7.0 in there?


s.add_development_dependency 'debug', '~> 1.9'
s.add_development_dependency 'rake', '~> 13.2'
Expand Down
Loading