ruby - rails console 显示的和数据库中条目不一致
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-04-24 15:59:13
0
1
666

rails console 里面没有全部显示数据库里面的数据。

数据库里有14条数据

mysql> select * from pages;
+----+------------+--------------+-----------+----------+---------+---------------------+---------------------+
| id | subject_id | name         | permalink | position | visible | created_at          | updated_at          |
+----+------------+--------------+-----------+----------+---------+---------------------+---------------------+
|  1 |          1 | First Page   |         0 |        1 |       0 | 2016-04-16 11:10:52 | 2016-04-16 11:10:52 |
|  2 |       NULL | Seconde Page |         0 |        2 |       0 | 2016-04-17 09:54:04 | 2016-04-17 09:54:04 |
|  3 |       NULL | Third Page   |         0 |        2 |       1 | 2016-04-17 06:32:04 | 2016-04-17 06:32:04 |
|  4 |       NULL | Forth Page   |         0 |        4 |       1 | 2016-04-17 06:33:18 | 2016-04-17 06:33:18 |
|  5 |       NULL | Fifth Page   |         0 |        5 |       1 | 2016-04-17 14:35:53 | 2016-04-17 14:35:53 |
|  6 |       NULL | Sixth Page   |         6 |        6 |       0 | 2016-04-18 14:33:22 | 2016-04-18 14:33:22 |
|  7 |       NULL | Seventh Page |         7 |        7 |       0 | 2016-04-18 14:35:22 | 2016-04-18 14:35:22 |
|  8 |       NULL | Seventh Page |         7 |        7 |       0 | 2016-04-18 14:41:50 | 2016-04-18 14:41:50 |
|  9 |       NULL | Seventh Page |         7 |        7 |       0 | 2016-04-18 14:41:57 | 2016-04-18 14:41:57 |
| 10 |       NULL | p10s         |         7 |        7 |       0 | 2016-04-18 14:41:58 | 2016-04-18 07:01:24 |
| 11 |         23 | page1        |         1 |        0 |       0 | 2016-04-28 07:29:29 | 2016-04-28 07:29:29 |
| 12 |         23 | k            |         0 |        0 |       0 | 2016-04-28 14:07:42 | 2016-04-28 14:07:42 |
| 13 |         23 | new page     |         3 |        3 |       0 | 2016-04-28 14:46:31 | 2016-04-28 14:46:31 |
| 14 |       NULL | page1        |        10 |        1 |       0 | 2016-04-28 14:50:51 | 2016-04-28 14:50:51 |
+----+------------+--------------+-----------+----------+---------+---------------------+---------------------+
14 rows in set (0.00 sec)

但在rails console里面只显示了10条

irb(main):001:0> Page.all
Page Load (0.5ms) SELECT pages.* FROM pages
=> #<ActiveRecord::Relation [#<Page id: 1, subject_id: 1, name: "First Page", permalink: 0, position: 1, visible: false, created_at: "2016-04-16 03:10:52", updated_at: "2016-04-16 03:10:52">, #<Page id: 2, subject_id: nil, name: "Seconde Page", permalink: 0, position: 2, visible: false, created_at: "2016-04-17 01:54:04", updated_at: "2016-04-17 01:54:04">, #<Page id: 3, subject_id: nil, name: "Third Page", permalink: 0, position: 2, visible: true, created_at: "2016-04-16 22:32:04", updated_at: "2016-04-16 22:32:04">, #<Page id: 4, subject_id: nil, name: "Forth Page", permalink: 0, position: 4, visible: true, created_at: "2016-04-16 22:33:18", updated_at: "2016-04-16 22:33:18">, #<Page id: 5, subject_id: nil, name: "Fifth Page", permalink: 0, position: 5, visible: true, created_at: "2016-04-17 06:35:53", updated_at: "2016-04-17 06:35:53">, #<Page id: 6, subject_id: nil, name: "Sixth Page", permalink: 6, position: 6, visible: false, created_at: "2016-04-18 06:33:22", updated_at: "2016-04-18 06:33:22">, #<Page id: 7, subject_id: nil, name: "Seventh Page", permalink: 7, position: 7, visible: false, created_at: "2016-04-18 06:35:22", updated_at: "2016-04-18 06:35:22">, #<Page id: 8, subject_id: nil, name: "Seventh Page", permalink: 7, position: 7, visible: false, created_at: "2016-04-18 06:41:50", updated_at: "2016-04-18 06:41:50">, #<Page id: 9, subject_id: nil, name: "Seventh Page", permalink: 7, position: 7, visible: false, created_at: "2016-04-18 06:41:57", updated_at: "2016-04-18 06:41:57">, #<Page id: 10, subject_id: nil, name: "p10s", permalink: 7, position: 7, visible: false, created_at: "2016-04-18 06:41:58", updated_at: "2016-04-17 23:01:24">, ...]>

曾经蜡笔没有小新
曾经蜡笔没有小新

全員に返信(1)
阿神

rails c で表示されるデータベースエントリのデフォルト数は 10 です。最後の省略記号を見ましたか?
アイテムの数を確認したい場合は、Page.countを使用できます

いいねを押す +0
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!