panoramic icon indicating copy to clipboard operation
panoramic copied to clipboard

Adding criteria to find_model_templates

Open asecondwill opened this issue 5 years ago • 2 comments

Is there a workflow to add criteria to the finder for templates, for example having different templates per user?

For that, I suppose we would have to somehow pass the @current_user to the finder in the controller, and for that to hook into panoramic.

asecondwill avatar Jul 24 '20 17:07 asecondwill

Hi there,

once you have a setup for the model to store store views, you might want to use the path field and, for example, store the user id of a specific view. Then you might use prepend_view_path TemplateStorage.resolver(:only => current_user.id) to search in virtual paths which have the user id prefix.

If you check the source code of this gem and/or check how rails templating works, you might find better solutions. Unfortunately, I'm not using rails since years, I'm just maintaining this gem to keep it working with newer versions of rails.

andreapavoni avatar Jul 27 '20 08:07 andreapavoni

OK, thanks for your comments. There is also the "additional_criteria" that can be added per render, although that seems like I'd have to add it to every render call on the site, which is a bit clunky. Your idea seems better.

asecondwill avatar Jul 27 '20 15:07 asecondwill