Sha256: 4cc8e2feb79037c9ef18395deac68196cb21a990c4e7a02ce01d149e8eac06f4
Contents?: true
Size: 743 Bytes
Versions: 5
Compression:
Stored size: 743 Bytes
Contents
module DataTable module ActiveRecord module ClassMethods def _find_objects params, fields, search_fields self.where(_where_conditions params[:sSearch], search_fields). order(_order_fields params, fields). paginate :page => _page(params), :per_page => params[:iDisplayLength] end def _where_conditions query, search_fields return if query.blank? [search_fields.map {|field| ["UPPER(#{field}) LIKE ?"] }.join(" OR "), *(["%#{query.upcase}%"] * search_fields.size)] end def _order_fields params, fields direction = params[:sSortDir_0] == "asc" ? "ASC" : "DESC" %{#{fields[params[:iSortCol_0].to_i]} #{direction}} end end end end
Version data entries
5 entries across 5 versions & 1 rubygems