Question

I'm trying to check if a value of an attribute is included in an array. Like that:

  @teste = []
  @vacancies_interns.each do |vacancy_intern|        
    @teste << vacancy_intern.id        
  end
  @hr_curriculum_interns = HrCurriculumIntern.where(@teste.include?(:id) == true) 

The output of the variable @teste, as an example, is: [5, 6, 8, 10, 12, 15]

I am listing the variable @ hr_curriculum_interns on a table, and even with the condition, is listing all table rows.

Sorry for English :P

Was it helpful?

Solution

It as simple as:

@hr_curriculum_interns = HrCurriculumIntern.where(id: @teste)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top