I am trying to retrieve a collection of data by an order like this:
@all_data= Data.find(@data_ids)
@data_ids
- have the ids of the data to be retrieved. For instance:
Data
ID Name
1 A
2 B
3 C
4 D
If the @data_ids
are like [3,2,4] I want to retrieve the data in that order, sou it would be C, B, D... The thing is it always retrieve the data in B, C, D order. Is that possible to do? To ignore that order and to retrieve it by the given params order?
The thing is,
I have two tables, table A and table Data.
Table A:
Relation, Data_ID, ORDER
1; 1; 2;
1; 2; 1;
2; 3; 3;
So what I want to do is to retrieve data_id by order from the relation one I will have (2,1), and I am doing it, but when I find (2,1) I receive 1,2.