Add default #render_in implementation to ActiveModel::Conversion#2
Open
seanpdoyle wants to merge 5 commits into
Open
Add default #render_in implementation to ActiveModel::Conversion#2seanpdoyle wants to merge 5 commits into
#render_in implementation to ActiveModel::Conversion#2seanpdoyle wants to merge 5 commits into
Conversation
9e9f75f to
bbff5f5
Compare
cb1b21b to
b554fd3
Compare
bbff5f5 to
af82a27
Compare
159b549 to
1ba6b9f
Compare
af82a27 to
6123414
Compare
8f14f10 to
39af464
Compare
39af464 to
1d390d1
Compare
4161fe4 to
94926db
Compare
465e84a to
98f1705
Compare
98f1705 to
56a1e49
Compare
56a1e49 to
97a7a97
Compare
77867f2 to
cd57c45
Compare
3b2546e to
7f2d39e
Compare
7f2d39e to
dbed3b1
Compare
dbed3b1 to
4c26fcd
Compare
a92e0e8 to
33d6dad
Compare
33d6dad to
1ea1ac5
Compare
1ea1ac5 to
50c601b
Compare
fdc3103 to
7614159
Compare
7614159 to
15f9f6a
Compare
c3a7449 to
01c275b
Compare
01c275b to
7185a7e
Compare
6123414 to
35e67cd
Compare
7185a7e to
e5267ad
Compare
We are migrating to megatest and we don't want to have two different styles of tests in the codebase. This commit changes all Arel tests to the test unit style.
e5267ad to
d24d0b7
Compare
Rewrite Arel tests using `ActiveSupport::TestCase` instead of `Minitest::Spec`
…options Pass render options and block to calls to `#render_in`
Follow-up to [rails#46202][] Without overriding the new `#render_in` method, previous behavior will be preserved: render the view partial determined by calling `#to_partial_path`, then pass `object: self`. With the following view partial: ```erb <%# app/views/people/_person.html.erb %> <% local_assigns.with_defaults(shout: false) => { shout: } %> <%= shout ? person.name.upcase : person.name %> ``` Callers can render an instance of `Person` as a positional argument or a `:renderable` option: ```ruby person = Person.new(name: "Ralph") render person # => "Ralph" render person, shout: true # => "RALPH" render renderable: person # => "Ralph" render renderable: person, locals: { shout: true } # => "RALPH" ``` This preserves backward compatibility. At the same time, the `#render_in` method provides applications with an more flexibility, and an opportunity to manage how to transform models into Strings. For example, users of ViewComponent can map a model directly to a `ViewComponent::Base` instance. [rails#46202]: rails#46202 (comment)
35e67cd to
241f2a0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #46202
Without overriding the new
#render_inmethod, previous behavior will be preserved: render the view partial determined by calling#to_partial_path, then passobject: self.With the following view partial:
Callers can render an instance of
Personas a positional argument or a:renderableoption:This preserves backward compatibility. At the same time, the
#render_inmethod provides applications with an more flexibility, and an opportunity to manage how to transform models into Strings. For example, users of ViewComponent can map a model directly to aViewComponent::Baseinstance.Summary
Other Information