Hmm what about something along the lines of:

```ruby 
all_config_templates = (nested_obj.present? ? "nested_obj.config_templates" : ConfigTemplate)
@config_templates = eval(all_config_templates).
                                          authorized(:view_templates).
                                          includes(:operatingsystems, :template_combinations, :template_kind).
                                          search_for(*search_options).paginate(paginate_options)
```

I hope there is some elegant way of delaying the db call (I'd say 'eval' in production code looks like a hack), but in the worst case this would put both pagination and search in the same db retrieval call.