0

I can't find a simple way to get the ids of pointfields from this relationship

pointtype has_and_belongs_to_many pointfields 
pointfield has_and_belongs_to_many pointtypes

I do the following :

@pointtypes = current_project.points.map{|p| p.pointtype}.uniq
@pointtypes = @pointtypes - [nil]                      # tricky... Is this Railsy ?
@pointfield_ids = @pointtypes.map(&:pointfield_ids)

returns

 [[16, 17, 18, 23, 24, 25, 26, 27, 28, 29], [16, 17, 32, 33, 34, 35, 36]]

and thus

@pointfield_ids.uniq!

is not working because there is two sub-arrays...

What I need is to get one single array with the unique ids of the pointfields (or the objects itself)

Stéphane V
  • 1,094
  • 2
  • 11
  • 25

0 Answers0