Created
September 23, 2014 14:00
-
-
Save operando/1a75c6dc3cfb0a23ea29 to your computer and use it in GitHub Desktop.
【Ruby on Rails】テーブルのレコード数を取得する - Model ref: http://qiita.com/operandoOS/items/f932ecac5a7e9cc9f098
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ActiveRecord::Base | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
User.count |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT count(*) AS count_all FROM users |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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