Rename filter method to filter_by

Ruby 2.6 introduces `Enumerable#filter` as an alias to
`Enumerable#select`, and so our Filterable.filter method will not work
with Ruby 2.6.

So we're renaming the method to `filter_by`, which is similar to
`find_by`. We could also change the `filter` method so if a block is
given it delegates to `Enumerable#filter`, the same way ActiveRecord
handles the `select` method, but IMHO this is easier to follow.
This commit is contained in:
Javi Martín
2020-08-22 23:30:53 +02:00
parent 09e4d2ec19
commit 9f689c21a2
3 changed files with 3 additions and 3 deletions

View File

@@ -9,7 +9,7 @@ module CommentableActions
@resources = @current_order == "recommendations" && current_user.present? ? @resources.recommendations(current_user) : @resources.for_render
@resources = @resources.search(@search_terms) if @search_terms.present?
@resources = @advanced_search_terms.present? ? @resources.filter(@advanced_search_terms) : @resources
@resources = @advanced_search_terms.present? ? @resources.filter_by(@advanced_search_terms) : @resources
@resources = @resources.page(params[:page]).send("sort_by_#{@current_order}")