app/controllers/services_controller.rb
# Filters the services displayed on the index page based on paramaters provided
Filters the services displayed on the index page based on paramaters provided
Filters the services displayed on the index page based on paramaters provided
def filter_services(search)
    return Service.where(true) if search.blank?
    @group = search[:group]
    @name = search[:name]
    @search_array = ["true"]
    @search_array << "services.name LIKE '%#{@name}%'" unless @name.blank? 
    @search_string = @search_array.join(" AND ")
    @services = Service.where(@search_string)
    @services = @services.joins(:employees => :groups).where("groups.id" => @group).uniq unless @group.blank?
    return @services
  end
def filter_services ( search ) return Service . where ( true ) if search . blank? @group = search [ :group ] @name = search [ :name ] @search_array = [ "true" ] @search_array << "services.name LIKE '%#{@name}%'" unless @name . blank? @search_string = @search_array . join ( " AND " ) @services = Service . where ( @search_string ) @services = @services . joins ( :employees => :groups ) . where ( "groups.id" => @group ) . uniq unless @group . blank? return @services end
Filters the services displayed on the index page based on paramaters provided
Filters the services displayed on the index page based on paramaters provided
search