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.
I'm using
rectify
at https://github.com/codegram/decidim/pull/147 and I'm having problems trying to render the results of a query object in a view using both these methods:I'm getting this error:
My first try was calling the
query
method on the query object in the view:This didn't raise any error, but didn't render anything actually so it's not useful. Also, explicitly calling this method from the view feels weird.
Checking the Rails source code, Rails tries to check if the collection passed to the
render
method responds toto_ary
. If it does not, it uses an empty array as the collection and thus it does not render anything (which is weird, actually):https://github.com/rails/rails/blob/28a6571bae1d6bc1c774e8e501720374061a31f1/actionview/lib/action_view/renderer/partial_renderer.rb#L406
So my take is defining the
to_ary
method in the Query class as an alias fromto_a
. Both the unit tests and the tests I took on my app are green with this change.