aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/time_tables_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/time_tables_controller.rb')
-rw-r--r--app/controllers/time_tables_controller.rb17
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}")