Sha256: 9daf271d27595388d5341d9b934f5353567520fff9a8fa6bdeb91c9a9f4e1a85
Contents?: true
Size: 623 Bytes
Versions: 21
Compression:
Stored size: 623 Bytes
Contents
module ChannelQueryBuilder def build_query_from_filters(q, filters) filters.each do |filter, value| q = method("add_filter_for_#{filter}".to_sym).call(q, value) end return q end # Fucntion to add a limit to a given query def add_filter_for_limit(q, limit) q.limit(limit) end def add_filter_for_category_id(q, category_id) q.joins(:categories).where(:ems_categories_channels => {:category_id => category_id}) end def add_filter_for_slug(q, slug) q.where(:slug => slug) end def add_filter_for_order_by(q, column) q.order column.to_sym end end
Version data entries
21 entries across 21 versions & 1 rubygems