#mine def self.keyword_search_mobile(attributes={}, user_attributes={}, offset = nil, limit = nil) scope = [] if !attributes[:search].blank? search = attributes.with_indifferent_access[:search] scope = self.all( :conditions => [ "short_desc ~* ? OR keywords ~* ? OR title ~* ?", /\y#{search}\y/, /\y#{search}\y/, /\y#{search}\y/ ] ) scope = scope.all(self.product_type_list.disable_on_mobile => false) scope = scope.all(offset: offset.to_i) if offset scope = scope.all(limit: limit.to_i) if limit end scope end #created by platform def keyword_search_mobile(attributes={}, user_attributes={}, offset = nil, limit = nil) scope = self.all if !attributes[:search].blank? scope = scope & all(:'short_desc' => attributes.with_indifferent_access[:search]) end scope = scope.all(:order => [:title.asc]) scope = scope.all(offset: offset.to_i) if offset scope = scope.all(limit: limit.to_i) if limit scope end #for mine to work with the params the way that ios sdk passes #you have to add with_indifferent_access to the check if the search attribute is blank def self.keyword_search_mobile(attributes={}, user_attributes={}, offset = nil, limit = nil) scope = [] if !attributes.with_indifferent_access[:search].blank? search = attributes.with_indifferent_access[:search] scope = self.all( :conditions => [ "short_desc ~* ? OR keywords ~* ? OR title ~* ?", /\y#{search}\y/, /\y#{search}\y/, /\y#{search}\y/ ] ) scope = scope.all(self.product_type_list.disable_on_mobile => false) scope = scope.all(offset: offset.to_i) if offset scope = scope.all(limit: limit.to_i) if limit end scope end