How to get the Nth row (or record) with Datamapper?

You can use request Ad. First :offset => rand(Ad. Count) but it invokes 2 SQL statements: SELECT COUNT(*) FROM "ads" SELECT "id" FROM "ads" ORDER BY "id" LIMIT 1 Also you can use raw SQL: repository.adapter.

Select "SELECT * FROM ads ORDER BY RANDOM() LIMIT 1.

You can use request Ad. First :offset => rand(Ad. Count), but it invokes 2 SQL statements: SELECT COUNT(*) FROM "ads" SELECT "id" FROM "ads" ORDER BY "id" LIMIT 1 Also you can use raw SQL: repository.adapter.

Select "SELECT * FROM ads ORDER BY RANDOM() LIMIT 1.

The Ad. First :offset => n part is what I was looking for in this case, thanks tons! Though in a real app I'd just use the raw sql, so thanks for that too.

– Nilloc May 16 at 13:23.

"to get the nth row with datamapper" - Google Search.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions