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
Add configuration to compatibility doc #1095
base: main
Are you sure you want to change the base?
Conversation
For some reason, my Rails 5.0.7.2 app had `nil` as the `view_component_path`. Why? I have no idea. This resolved the issue for me. I am not sure if it's appropriate but I figured it couldn't hurt to add it to the compatibility doc.
|
@dpaola2 thanks for filing. Might you be up for trying to get a failing build that this change fixes? I'd hate for us to accidentally break this fix in the future. |
* main/main: Bump nokogiri from 1.11.5 to 1.12.5 in /docs (github#1081) Fix CI (github#1097)
|
@joelhawksley Here you go. Just adding the rails version replicated the issue, with the same unhandled exception I saw in my app. I spent a bit of time trying to figure out why this might be but it wasn't obvious at first glance. |
|
It stems from this: view_component/lib/view_component/base.rb Line 282 in d6d04e8
Support for the So, the same issue would affect Rails 5.1 apps as well. It's worth noting that only Rails 5.2 (and not earlier 5.x versions) is still officially supported by Rails (in that it still receives security patches), but even Rails 5.2 support will be dropped when Rails 7 is released. That said, it's possible to address this issue without committing ViewComponent to officially support Rails 5.0/5.1 (but note that there are additional |
|
Makes sense. FWIW the official docs (in |
|
@dpaola2 it looks like this build is still failing due to other incompatibilities with Rails 5. Would you be up for fixing them? I assume you're looking to use VC with Rails 5.0 and would be happy to accept any (reasonable) patches to make that possible. |
|
I took the easy path and skipped some tests:
Also:
So I'd like to request the opinion of the maintainers on this: should we spend a bit more time on this and merge it, or just change the docs to mention compatibility with Rails 5.2+ only? |
| # config.view_component.render_monkey_patch_enabled = false | ||
| # | ||
| mattr_accessor :render_monkey_patch_enabled, instance_writer: false, default: true | ||
| if Rails.version.to_f >= 5.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think passing a block is supported in all the Rails versions we want to support, so what if we always pass a block here and avoid the Rails version check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, but the newer syntax is with the default: keyword argument, that's why I went with it.
Either way is fine with me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The nice thing about the block approach is that it's only called if no value has been provided, meaning it could potentially cut down on unnecessary object allocations. I can't imagine it'd save that many, but still worth considering.
| @@ -3,85 +3,87 @@ | |||
| require "test_helper" | |||
|
|
|||
| class TranslatableTest < ViewComponent::TestCase | |||
| def test_isolated_translations | |||
| render_inline(TranslatableComponent.new) | |||
| if Rails.version.to_f >= 5.2 | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm so all these tests only work if the Rails version is 5.2 or later? Why is that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is more work needed to make Translatable work with Rails < 5.2. I wanted to know if y'all think it's worth it to spend more time trying to support older Rails before tackling this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should support up to 5.2 since that's the oldest currently supported version. If adding support for < 5.2 were easy, I'd say let's go for it. Since it's more difficult, I'm inclined to say no.

Summary
For some reason, my Rails 5.0.7.2 app had
nilas theview_component_path. Why? I have no idea. This resolved the issue for me. I am not sure if it's appropriate but I figured it couldn't hurt to add it to the compatibility doc.