diff options
| author | Xinhui | 2017-04-11 15:51:23 +0200 |
|---|---|---|
| committer | Xinhui | 2017-04-11 15:51:27 +0200 |
| commit | fd99f21e549e2141d81cedbbe21ee563af3a379f (patch) | |
| tree | c441ace717b0e530fae21affc85bc53d29770be9 /app/controllers | |
| parent | cb52e18005ee03db7d071418217cdcddaa44cec1 (diff) | |
| download | chouette-core-fd99f21e549e2141d81cedbbe21ee563af3a379f.tar.bz2 | |
TimeTable#index fix search by comment_cont
Refs #2909
Diffstat (limited to 'app/controllers')
| -rw-r--r-- | app/controllers/time_tables_controller.rb | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/app/controllers/time_tables_controller.rb b/app/controllers/time_tables_controller.rb index cb7c96e03..cd682a741 100644 --- a/app/controllers/time_tables_controller.rb +++ b/app/controllers/time_tables_controller.rb @@ -93,14 +93,17 @@ class TimeTablesController < ChouetteController protected def collection - ransack_params = params[:q] - # Hack to delete params can't be used by ransack - tag_search = ransack_params["tag_search"] if ransack_params.present? && ransack_params["tag_search"].present? - ransack_params.delete("tag_search") if ransack_params.present? - - selected_time_tables = tag_search ? select_time_tables.tagged_with(tag_search, :wild => true, :any => true) : select_time_tables + scope = select_time_tables + if params[:q] && params[:q]["tag_search"] + tags = params[:q]["tag_search"].reject {|c| c.empty?} + if tags.any? + # Hack to delete params can't be used by ransack + params[:q].delete("tag_search") + scope = select_time_tables.tagged_with(tags, :wild => true, :any => true) + end + end - @q = selected_time_tables.search(ransack_params) + @q = scope.search(params[:q]) if sort_column && sort_direction @time_tables ||= @q.result(:distinct => true).order("#{sort_column} #{sort_direction}") |
