Hi can someone tell me what went wrong here?
@organizations_of_user = user.memberships.verified.pluck :organization_id
@organizations_of_user << nil
@permitted_category_ids= Category.where(......, organization_id:@organizations_of_user)
seems like the @organizations_of_user has some problems. This code is written by one of my previous colleague. I don't know what exactly this << nil is doing, but somehow, without this, the code crashes. But with this, the Category scope will only display organization_id : nil.
does someone have any idea?
Thanks a lot!
@organizations_of_user is an array
@organizations_of_user = user.memberships.verified.pluck(:organization_id) #Extracts organization_ids in an array [1,2,3...]
@organizations_of_user << nil # Adds nil to the array [1,2,3,nil...]
@permitted_category_ids= Category.where(......, organization_id:@organizations_of_user) #Search for Categories with organization_ids inside the array [1,2,3,nil...]. (nil extracts Categories without an organization_id)