I get an array of search results from tire, containing objects of various activemodel types, and I need to render each to a string. Currently, I am doing this with a loop over these results calling render_to_string(result) on each. This uses the default partial for that activemodel object.
However, this requires that I set the default partial for every class I want to be searchable to be the representation for search. This means that everywhere else in the code I need to explicitly render a collection (all of the same type) I need to explicitly specify to render with my general-use partial, when really that general use partial should be the default. It also raises the question of what I would do if I needed to render a different collection of various types, as it would use the same partials as the search.
What I would really like would be to be able to pass a prefix to render_to_string that would tell it to look for the default partial, but inside this directory - which would mean I can keep my search partials separate while still being able easily render the objects.
Is there a way of doing that or some other better solution?
render_to_string([:search, result])?':search' is not an ActiveModel-compatible object that returns a valid partial path.