DMPbelgium / roadmap

5 stars 1 forks source link

Paginable::TemplatesController#organisational crashes when parameter `search` is given. #44

Open nicolasfranck opened 2 years ago

nicolasfranck commented 2 years ago

See https://github.com/DMPRoadmap/roadmap/issues/3156

nicolasfranck commented 2 years ago

In lay terms: if the page of organisational templates in the org admin is long enough, and you can type in a search query in the search bar, then the page crashes.

Reproduce:

StCyr commented 1 year ago

I haven't investigated much but changing search method in file app/models/templates.rb as follow (so removing the joins'(org) clause) seems to return a better result:

  # Retrieves unarchived templates whose title or org.name includes the term
  # passed
  scope :search, lambda { |term|
    #unarchived.joins(:org)
    unarchived.where('lower(templates.title) LIKE lower(:term) OR ' \
                     'lower(orgs.name) LIKE lower(:term)',
                     term: "%#{term}%")
  }