Position of object in database

Posted by fl00r on Stack Overflow See other posts from Stack Overflow or by fl00r
Published on 2010-05-04T08:23:07Z Indexed on 2010/05/04 8:28 UTC
Read the original article Hit count: 237

Filed under:
|
|
|

Hi!

I have got model Team and I've got (i.e.) team = Team.first :offset => 20. Now I need to get number of position of my team in db table.

I can do it in ruby:

Team.all.index team #=> 20

But I am sure that I can write it on SQL and it will be less expensive for me with big tables.

© Stack Overflow or respective owner

Related posts about ruby

Related posts about activerecord