Skip to content

Instantly share code, notes, and snippets.

View cdsandoval's full-sized avatar
🧑‍💻
Becoming a Full Stack Web Developer

Carlos Sandoval Montoya cdsandoval

🧑‍💻
Becoming a Full Stack Web Developer
View GitHub Profile
@cdsandoval
cdsandoval / helper.js
Last active June 9, 2023 17:55
Refactor ransack fiilter with search term
function buildSearchGroups(term, searchFields) {
const searchGroups = [];
if (term) {
const searchTermList = term.trim().split(' ');
searchTermList.forEach(searchTerm => {
const searchGroup = { m: 'or' };
searchFields.forEach(field => {