Skip to content

Instantly share code, notes, and snippets.

@operando
Created September 23, 2014 14:00
Show Gist options
  • Save operando/1a75c6dc3cfb0a23ea29 to your computer and use it in GitHub Desktop.
Save operando/1a75c6dc3cfb0a23ea29 to your computer and use it in GitHub Desktop.
【Ruby on Rails】テーブルのレコード数を取得する - Model ref: http://qiita.com/operandoOS/items/f932ecac5a7e9cc9f098
class User < ActiveRecord::Base
end
SELECT count(*) AS count_all FROM users
User.find_by_id(rand(User.count) + 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment