Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## test.rb
- user = User.new(:login => "bruce")
- user.password = user.password_confirmation = "wayne"
- user.save
- blog = Blog.new(:author => user, :title => "bruce's blog")
- blog.save
- 20.times do |i|
- blog.posts.create :author => user, :title => "posting #{i}", :content => "content"
- end
- postings = blog.posts.paginate 3
- title = postings[1].title
- ## log.txt (queries only)
- ~ (0.016885) INSERT INTO "users" ("crypted_password", "login", "salt") VALUES ('8dbd1cc548ca0581ec5f5d84bafc884b04ec9a3e', 'bruce', 'a36b69aea7898e3c1f3e613a638c154aeae55a70')
- ~ (0.009863) INSERT INTO "blogs" ("title", "user_id") VALUES ('bruce''s blog', 1)
- ~ (0.000283) SELECT "id", "title", "updated_at", "created_at", "blog_id", "user_id" FROM "posts" WHERE ("blog_id" IN (1)) ORDER BY "id" DESC
- ~ (0.006578) INSERT INTO "posts" ("updated_at", "title", "blog_id", "user_id", "created_at", "content") VALUES ('2009-08-11T08:40:28-04:00', 'posting 0', 1, 1, '2009-08-11T08:40:28-04:00', 'content')
- ~ (0.008513) INSERT INTO "posts" ("updated_at", "title", "blog_id", "user_id", "created_at", "content") VALUES ('2009-08-11T08:40:28-04:00', 'posting 1', 1, 1, '2009-08-11T08:40:28-04:00', 'content')
- ~ (0.007068) INSERT INTO "posts" ("updated_at", "title", "blog_id", "user_id", "created_at", "content") VALUES ('2009-08-11T08:40:28-04:00', 'posting 2', 1, 1, '2009-08-11T08:40:28-04:00', 'content')
- ~ (0.008977) INSERT INTO "posts" ("updated_at", "title", "blog_id", "user_id", "created_at", "content") VALUES ('2009-08-11T08:40:28-04:00', 'posting 3', 1, 1, '2009-08-11T08:40:28-04:00', 'content')
- ~ (0.007042) INSERT INTO "posts" ("updated_at", "title", "blog_id", "user_id", "created_at", "content") VALUES ('2009-08-11T08:40:28-04:00', 'posting 4', 1, 1, '2009-08-11T08:40:28-04:00', 'content')
- ~ (0.009184) INSERT INTO "posts" ("updated_at", "title", "blog_id", "user_id", "created_at", "content") VALUES ('2009-08-11T08:40:28-04:00', 'posting 5', 1, 1, '2009-08-11T08:40:28-04:00', 'content')
- ~ (0.008876) INSERT INTO "posts" ("updated_at", "title", "blog_id", "user_id", "created_at", "content") VALUES ('2009-08-11T08:40:28-04:00', 'posting 6', 1, 1, '2009-08-11T08:40:28-04:00', 'content')
- ~ (0.011913) INSERT INTO "posts" ("updated_at", "title", "blog_id", "user_id", "created_at", "content") VALUES ('2009-08-11T08:40:29-04:00', 'posting 7', 1, 1, '2009-08-11T08:40:29-04:00', 'content')
- ~ (0.009535) INSERT INTO "posts" ("updated_at", "title", "blog_id", "user_id", "created_at", "content") VALUES ('2009-08-11T08:40:29-04:00', 'posting 8', 1, 1, '2009-08-11T08:40:29-04:00', 'content')
- ~ (0.008395) INSERT INTO "posts" ("updated_at", "title", "blog_id", "user_id", "created_at", "content") VALUES ('2009-08-11T08:40:29-04:00', 'posting 9', 1, 1, '2009-08-11T08:40:29-04:00', 'content')
- ~ (0.009611) INSERT INTO "posts" ("updated_at", "title", "blog_id", "user_id", "created_at", "content") VALUES ('2009-08-11T08:40:29-04:00', 'posting 10', 1, 1, '2009-08-11T08:40:29-04:00', 'content')
- ~ (0.008224) INSERT INTO "posts" ("updated_at", "title", "blog_id", "user_id", "created_at", "content") VALUES ('2009-08-11T08:40:29-04:00', 'posting 11', 1, 1, '2009-08-11T08:40:29-04:00', 'content')
- ~ (0.009501) INSERT INTO "posts" ("updated_at", "title", "blog_id", "user_id", "created_at", "content") VALUES ('2009-08-11T08:40:29-04:00', 'posting 12', 1, 1, '2009-08-11T08:40:29-04:00', 'content')
- ~ (0.008180) INSERT INTO "posts" ("updated_at", "title", "blog_id", "user_id", "created_at", "content") VALUES ('2009-08-11T08:40:29-04:00', 'posting 13', 1, 1, '2009-08-11T08:40:29-04:00', 'content')
- ~ (0.008648) INSERT INTO "posts" ("updated_at", "title", "blog_id", "user_id", "created_at", "content") VALUES ('2009-08-11T08:40:29-04:00', 'posting 14', 1, 1, '2009-08-11T08:40:29-04:00', 'content')
- ~ (0.008189) INSERT INTO "posts" ("updated_at", "title", "blog_id", "user_id", "created_at", "content") VALUES ('2009-08-11T08:40:29-04:00', 'posting 15', 1, 1, '2009-08-11T08:40:29-04:00', 'content')
- ~ (0.007594) INSERT INTO "posts" ("updated_at", "title", "blog_id", "user_id", "created_at", "content") VALUES ('2009-08-11T08:40:29-04:00', 'posting 16', 1, 1, '2009-08-11T08:40:29-04:00', 'content')
- ~ (0.010952) INSERT INTO "posts" ("updated_at", "title", "blog_id", "user_id", "created_at", "content") VALUES ('2009-08-11T08:40:29-04:00', 'posting 17', 1, 1, '2009-08-11T08:40:29-04:00', 'content')
- ~ (0.009643) INSERT INTO "posts" ("updated_at", "title", "blog_id", "user_id", "created_at", "content") VALUES ('2009-08-11T08:40:29-04:00', 'posting 18', 1, 1, '2009-08-11T08:40:29-04:00', 'content')
- ~ (0.007743) INSERT INTO "posts" ("updated_at", "title", "blog_id", "user_id", "created_at", "content") VALUES ('2009-08-11T08:40:29-04:00', 'posting 19', 1, 1, '2009-08-11T08:40:29-04:00', 'content')
- ~ (0.000230) SELECT "id", "title", "updated_at", "created_at", "blog_id", "user_id" FROM "posts" WHERE ("blog_id" IN (1)) AND ("id" IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)) ORDER BY "id" DESC LIMIT 1 OFFSET 5
Add Comment
Please, Sign In to add comment