Rails:元搜索在限定范围和分页时会中断吗?
我有一组可搜索的照片,我想将索引页的结果限制为公开的结果(即不属于私人收藏,又名。 :collection_id=>nil
)。
我的模型中有以下范围:
scope :community, where(:collection_id => nil)
我的控制器中有以下内容:
def index
@search = Photo.community.search(params[:search])
@photos = @search.page(params[:page]).per(20)
end
我正在使用 Kaminari 对结果进行分页。
当我搜索未指定范围的照片(即 Photo.search(params[:search])
)时,它工作正常。但是,当我使用此范围搜索照片时,分页会中断搜索。第一页显示正确,但当我转到另一页时没有结果。为了在本地测试这一点,我将分页更改为每页 1,但无论我在第一页之后搜索任何页面,仍然没有显示任何结果,即使分页器指示还有更多页面的结果。
我不知道如何调试和修复这个问题,我真的需要一些帮助。以下是来自开发日志的 SQL:
对于索引页的正常加载(无搜索):
Started GET "/photos" for 127.0.0.1 at 2011-04-28 11:58:51 -0500
Processing by PhotosController#index as HTML
SQL (0.4ms) SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
SQL (0.3ms) SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
User Load (0.7ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
Context Load (0.3ms) SELECT "contexts".* FROM "contexts" ORDER BY "contexts"."display_order" ASC
Focus Load (0.3ms) SELECT "focus".* FROM "focus" ORDER BY "focus"."display_order" ASC
LandUse Load (0.3ms) SELECT "land_uses".* FROM "land_uses" ORDER BY "land_uses"."display_order" ASC
Rendered static/_help-context.html.haml (4.5ms)
Rendered static/_help-focus.html.haml (3.1ms)
Rendered photos/_search.html.haml (304.9ms)
SQL (0.5ms) SELECT COUNT(DISTINCT "photos"."id") FROM "photos" LEFT OUTER JOIN "attachments" ON "attachments"."photo_id" = "photos"."id" LEFT OUTER JOIN "collections" ON "collections"."id" = "photos"."collection_id" WHERE "photos"."collection_id" IS NULL LIMIT 1 OFFSET 0
Photo Load (1.0ms) SELECT "photos".* FROM "photos" WHERE "photos"."collection_id" IS NULL LIMIT 1 OFFSET 0
Attachment Load (0.2ms) SELECT "attachments".* FROM "attachments" WHERE ("attachments".photo_id = 1)
User Load (1.0ms) SELECT "users".* FROM "users" WHERE ("users"."id" = 1)
Profile Load (1.7ms) SELECT "profiles".* FROM "profiles" WHERE ("profiles".user_id = 1) LIMIT 1
Context Load (0.2ms) SELECT "contexts".* FROM "contexts" WHERE "contexts"."id" = 6 ORDER BY "contexts"."display_order" ASC LIMIT 1
Focus Load (0.1ms) SELECT "focus".* FROM "focus" WHERE "focus"."id" = 2 ORDER BY "focus"."display_order" ASC LIMIT 1
LandUse Load (0.2ms) SELECT * FROM "land_uses" INNER JOIN "land_uses_photos" ON "land_uses".id = "land_uses_photos".land_use_id WHERE ("land_uses_photos".photo_id = 1 ) ORDER BY "land_uses"."display_order" ASC
Rendered photos/_photo_tiles.html.haml (62.2ms)
SQL (0.2ms) SELECT COUNT(DISTINCT "photos"."id") FROM "photos" LEFT OUTER JOIN "attachments" ON "attachments"."photo_id" = "photos"."id" LEFT OUTER JOIN "collections" ON "collections"."id" = "photos"."collection_id" WHERE "photos"."collection_id" IS NULL
Rendered shared/_feedback.html.haml (1.5ms)
Role Load (0.5ms) SELECT "roles".* FROM "roles" INNER JOIN "roles_users" ON "roles".id = "roles_users".role_id WHERE "roles"."name" = 'admin' AND ("roles_users".user_id = 1 ) LIMIT 1
CACHE (0.0ms) SELECT "profiles".* FROM "profiles" WHERE ("profiles".user_id = 1) LIMIT 1
CACHE (0.0ms) SELECT "roles".* FROM "roles" INNER JOIN "roles_users" ON "roles".id = "roles_users".role_id WHERE "roles"."name" = 'admin' AND ("roles_users".user_id = 1 ) LIMIT 1
Rendered shared/_menu.html.haml (177.6ms)
Rendered shared/_footer.html.haml (2.7ms)
Rendered photos/index.html.haml within layouts/application (897.1ms)
Completed 200 OK in 1158ms (Views: 912.2ms | ActiveRecord: 8.2ms)
对于搜索的第一页(正常工作):
Started GET "/photos?utf8=%E2%9C%93&search%5Bcontext_id_in%5D%5B%5D=6&search%5Btagged_with%5D=&search%5Btext_contains%5D=&search%5Bnear%5D%5B%5D=&search%5Bnear%5D%5B%5D=100&commit=Search" for 127.0.0.1 at 2011-04-28 12:00:39 -0500
Processing by PhotosController#index as HTML
Parameters: {"utf8"=>"✓", "search"=>{"context_id_in"=>["6"], "tagged_with"=>"", "text_contains"=>"", "near"=>["", "100"]}, "commit"=>"Search"}
SQL (0.4ms) SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
SQL (0.3ms) SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
User Load (0.6ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
Context Load (0.4ms) SELECT "contexts".* FROM "contexts" ORDER BY "contexts"."display_order" ASC
Focus Load (0.3ms) SELECT "focus".* FROM "focus" ORDER BY "focus"."display_order" ASC
LandUse Load (0.4ms) SELECT "land_uses".* FROM "land_uses" ORDER BY "land_uses"."display_order" ASC
Rendered static/_help-context.html.haml (4.6ms)
Rendered static/_help-focus.html.haml (3.1ms)
Rendered photos/_search.html.haml (161.0ms)
SQL (0.4ms) SELECT COUNT(DISTINCT "photos"."id") FROM "photos" LEFT OUTER JOIN "attachments" ON "attachments"."photo_id" = "photos"."id" LEFT OUTER JOIN "collections" ON "collections"."id" = "photos"."collection_id" WHERE "photos"."collection_id" IS NULL AND "photos"."context_id" IN (6) LIMIT 1 OFFSET 0
Photo Load (0.7ms) SELECT "photos".* FROM "photos" WHERE "photos"."collection_id" IS NULL AND "photos"."context_id" IN (6) LIMIT 1 OFFSET 0
Attachment Load (0.2ms) SELECT "attachments".* FROM "attachments" WHERE ("attachments".photo_id = 1)
User Load (0.9ms) SELECT "users".* FROM "users" WHERE ("users"."id" = 1)
Profile Load (1.9ms) SELECT "profiles".* FROM "profiles" WHERE ("profiles".user_id = 1) LIMIT 1
Context Load (0.2ms) SELECT "contexts".* FROM "contexts" WHERE "contexts"."id" = 6 ORDER BY "contexts"."display_order" ASC LIMIT 1
Focus Load (0.2ms) SELECT "focus".* FROM "focus" WHERE "focus"."id" = 2 ORDER BY "focus"."display_order" ASC LIMIT 1
LandUse Load (0.2ms) SELECT * FROM "land_uses" INNER JOIN "land_uses_photos" ON "land_uses".id = "land_uses_photos".land_use_id WHERE ("land_uses_photos".photo_id = 1 ) ORDER BY "land_uses"."display_order" ASC
Rendered photos/_photo_tiles.html.haml (204.2ms)
SQL (0.3ms) SELECT COUNT(DISTINCT "photos"."id") FROM "photos" LEFT OUTER JOIN "attachments" ON "attachments"."photo_id" = "photos"."id" LEFT OUTER JOIN "collections" ON "collections"."id" = "photos"."collection_id" WHERE "photos"."collection_id" IS NULL AND "photos"."context_id" IN (6)
Rendered shared/_feedback.html.haml (1.3ms)
Role Load (0.4ms) SELECT "roles".* FROM "roles" INNER JOIN "roles_users" ON "roles".id = "roles_users".role_id WHERE "roles"."name" = 'admin' AND ("roles_users".user_id = 1 ) LIMIT 1
CACHE (0.0ms) SELECT "profiles".* FROM "profiles" WHERE ("profiles".user_id = 1) LIMIT 1
CACHE (0.0ms) SELECT "roles".* FROM "roles" INNER JOIN "roles_users" ON "roles".id = "roles_users".role_id WHERE "roles"."name" = 'admin' AND ("roles_users".user_id = 1 ) LIMIT 1
Rendered shared/_menu.html.haml (35.5ms)
Rendered shared/_footer.html.haml (2.9ms)
Rendered photos/index.html.haml within layouts/application (729.3ms)
Completed 200 OK in 990ms (Views: 728.5ms | ActiveRecord: 7.7ms)
对于搜索的第二页(即使结果存在,也不显示结果):
Started GET "/photos?commit=Search&page=2&search[context_id_in][]=6&search[near][]=&search[near][]=100&search[tagged_with]=&search[text_contains]=&utf8=%E2%9C%93" for 127.0.0.1 at 2011-04-28 12:01:33 -0500
Processing by PhotosController#index as HTML
Parameters: {"commit"=>"Search", "page"=>"2", "search"=>{"context_id_in"=>["6"], "near"=>["", "100"], "tagged_with"=>"", "text_contains"=>""}, "utf8"=>"✓"}
SQL (0.4ms) SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
SQL (0.3ms) SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
User Load (0.7ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
Context Load (0.3ms) SELECT "contexts".* FROM "contexts" ORDER BY "contexts"."display_order" ASC
Focus Load (0.3ms) SELECT "focus".* FROM "focus" ORDER BY "focus"."display_order" ASC
LandUse Load (0.3ms) SELECT "land_uses".* FROM "land_uses" ORDER BY "land_uses"."display_order" ASC
Rendered static/_help-context.html.haml (4.9ms)
Rendered static/_help-focus.html.haml (3.4ms)
Rendered photos/_search.html.haml (307.8ms)
SQL (0.3ms) SELECT COUNT(DISTINCT "photos"."id") FROM "photos" LEFT OUTER JOIN "attachments" ON "attachments"."photo_id" = "photos"."id" LEFT OUTER JOIN "collections" ON "collections"."id" = "photos"."collection_id" WHERE "photos"."collection_id" IS NULL AND "photos"."context_id" IN (6) LIMIT 1 OFFSET 1
SQL (0.3ms) SELECT COUNT(DISTINCT "photos"."id") FROM "photos" LEFT OUTER JOIN "attachments" ON "attachments"."photo_id" = "photos"."id" LEFT OUTER JOIN "collections" ON "collections"."id" = "photos"."collection_id" WHERE "photos"."collection_id" IS NULL AND "photos"."context_id" IN (6)
Rendered shared/_feedback.html.haml (1.5ms)
Role Load (0.4ms) SELECT "roles".* FROM "roles" INNER JOIN "roles_users" ON "roles".id = "roles_users".role_id WHERE "roles"."name" = 'admin' AND ("roles_users".user_id = 1 ) LIMIT 1
Profile Load (1.6ms) SELECT "profiles".* FROM "profiles" WHERE ("profiles".user_id = 1) LIMIT 1
CACHE (0.0ms) SELECT "roles".* FROM "roles" INNER JOIN "roles_users" ON "roles".id = "roles_users".role_id WHERE "roles"."name" = 'admin' AND ("roles_users".user_id = 1 ) LIMIT 1
Rendered shared/_menu.html.haml (209.5ms)
Rendered shared/_footer.html.haml (2.7ms)
Rendered photos/index.html.haml within layouts/application (822.3ms)
Completed 200 OK in 934ms (Views: 823.7ms | ActiveRecord: 5.1ms)
再次注意,在上面的日志中,我已将分页设置为每页 1,这样我就可以查看分页器是否显示了正确的结果数量,事实确实如此。例如,如果我搜索我知道的内容,每页有 3 个匹配项,分页器会显示有三页结果,但第 2 页和第 3 页是空白的。
我完全被难住了,任何帮助将不胜感激。
I have a searchable set of photos, and I want to limit the results for the index page to ones that are public (ie don't belong to a private collection, aka. :collection_id=>nil
).
I have the following scope in my model:
scope :community, where(:collection_id => nil)
I have the following in my controller:
def index
@search = Photo.community.search(params[:search])
@photos = @search.page(params[:page]).per(20)
end
I'm using Kaminari to paginate the results.
When I search photos unscoped (ie Photo.search(params[:search])
) it works fine. However, when I search for photos using this scope pagination breaks the search. The first page shows up correctly, but when I go to another page there are no results. To test this locally I changed pagination to 1 per page and still no matter what I search for any pages after the first page show no results even though the paginator indicates that there are many more pages of results.
I have no idea how to debug and fix this, and I would really use some help. Here's the SQL from the development log:
For a normal load of the index page (no search):
Started GET "/photos" for 127.0.0.1 at 2011-04-28 11:58:51 -0500
Processing by PhotosController#index as HTML
SQL (0.4ms) SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
SQL (0.3ms) SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
User Load (0.7ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
Context Load (0.3ms) SELECT "contexts".* FROM "contexts" ORDER BY "contexts"."display_order" ASC
Focus Load (0.3ms) SELECT "focus".* FROM "focus" ORDER BY "focus"."display_order" ASC
LandUse Load (0.3ms) SELECT "land_uses".* FROM "land_uses" ORDER BY "land_uses"."display_order" ASC
Rendered static/_help-context.html.haml (4.5ms)
Rendered static/_help-focus.html.haml (3.1ms)
Rendered photos/_search.html.haml (304.9ms)
SQL (0.5ms) SELECT COUNT(DISTINCT "photos"."id") FROM "photos" LEFT OUTER JOIN "attachments" ON "attachments"."photo_id" = "photos"."id" LEFT OUTER JOIN "collections" ON "collections"."id" = "photos"."collection_id" WHERE "photos"."collection_id" IS NULL LIMIT 1 OFFSET 0
Photo Load (1.0ms) SELECT "photos".* FROM "photos" WHERE "photos"."collection_id" IS NULL LIMIT 1 OFFSET 0
Attachment Load (0.2ms) SELECT "attachments".* FROM "attachments" WHERE ("attachments".photo_id = 1)
User Load (1.0ms) SELECT "users".* FROM "users" WHERE ("users"."id" = 1)
Profile Load (1.7ms) SELECT "profiles".* FROM "profiles" WHERE ("profiles".user_id = 1) LIMIT 1
Context Load (0.2ms) SELECT "contexts".* FROM "contexts" WHERE "contexts"."id" = 6 ORDER BY "contexts"."display_order" ASC LIMIT 1
Focus Load (0.1ms) SELECT "focus".* FROM "focus" WHERE "focus"."id" = 2 ORDER BY "focus"."display_order" ASC LIMIT 1
LandUse Load (0.2ms) SELECT * FROM "land_uses" INNER JOIN "land_uses_photos" ON "land_uses".id = "land_uses_photos".land_use_id WHERE ("land_uses_photos".photo_id = 1 ) ORDER BY "land_uses"."display_order" ASC
Rendered photos/_photo_tiles.html.haml (62.2ms)
SQL (0.2ms) SELECT COUNT(DISTINCT "photos"."id") FROM "photos" LEFT OUTER JOIN "attachments" ON "attachments"."photo_id" = "photos"."id" LEFT OUTER JOIN "collections" ON "collections"."id" = "photos"."collection_id" WHERE "photos"."collection_id" IS NULL
Rendered shared/_feedback.html.haml (1.5ms)
Role Load (0.5ms) SELECT "roles".* FROM "roles" INNER JOIN "roles_users" ON "roles".id = "roles_users".role_id WHERE "roles"."name" = 'admin' AND ("roles_users".user_id = 1 ) LIMIT 1
CACHE (0.0ms) SELECT "profiles".* FROM "profiles" WHERE ("profiles".user_id = 1) LIMIT 1
CACHE (0.0ms) SELECT "roles".* FROM "roles" INNER JOIN "roles_users" ON "roles".id = "roles_users".role_id WHERE "roles"."name" = 'admin' AND ("roles_users".user_id = 1 ) LIMIT 1
Rendered shared/_menu.html.haml (177.6ms)
Rendered shared/_footer.html.haml (2.7ms)
Rendered photos/index.html.haml within layouts/application (897.1ms)
Completed 200 OK in 1158ms (Views: 912.2ms | ActiveRecord: 8.2ms)
For the first page of a search (works correctly):
Started GET "/photos?utf8=%E2%9C%93&search%5Bcontext_id_in%5D%5B%5D=6&search%5Btagged_with%5D=&search%5Btext_contains%5D=&search%5Bnear%5D%5B%5D=&search%5Bnear%5D%5B%5D=100&commit=Search" for 127.0.0.1 at 2011-04-28 12:00:39 -0500
Processing by PhotosController#index as HTML
Parameters: {"utf8"=>"✓", "search"=>{"context_id_in"=>["6"], "tagged_with"=>"", "text_contains"=>"", "near"=>["", "100"]}, "commit"=>"Search"}
SQL (0.4ms) SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
SQL (0.3ms) SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
User Load (0.6ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
Context Load (0.4ms) SELECT "contexts".* FROM "contexts" ORDER BY "contexts"."display_order" ASC
Focus Load (0.3ms) SELECT "focus".* FROM "focus" ORDER BY "focus"."display_order" ASC
LandUse Load (0.4ms) SELECT "land_uses".* FROM "land_uses" ORDER BY "land_uses"."display_order" ASC
Rendered static/_help-context.html.haml (4.6ms)
Rendered static/_help-focus.html.haml (3.1ms)
Rendered photos/_search.html.haml (161.0ms)
SQL (0.4ms) SELECT COUNT(DISTINCT "photos"."id") FROM "photos" LEFT OUTER JOIN "attachments" ON "attachments"."photo_id" = "photos"."id" LEFT OUTER JOIN "collections" ON "collections"."id" = "photos"."collection_id" WHERE "photos"."collection_id" IS NULL AND "photos"."context_id" IN (6) LIMIT 1 OFFSET 0
Photo Load (0.7ms) SELECT "photos".* FROM "photos" WHERE "photos"."collection_id" IS NULL AND "photos"."context_id" IN (6) LIMIT 1 OFFSET 0
Attachment Load (0.2ms) SELECT "attachments".* FROM "attachments" WHERE ("attachments".photo_id = 1)
User Load (0.9ms) SELECT "users".* FROM "users" WHERE ("users"."id" = 1)
Profile Load (1.9ms) SELECT "profiles".* FROM "profiles" WHERE ("profiles".user_id = 1) LIMIT 1
Context Load (0.2ms) SELECT "contexts".* FROM "contexts" WHERE "contexts"."id" = 6 ORDER BY "contexts"."display_order" ASC LIMIT 1
Focus Load (0.2ms) SELECT "focus".* FROM "focus" WHERE "focus"."id" = 2 ORDER BY "focus"."display_order" ASC LIMIT 1
LandUse Load (0.2ms) SELECT * FROM "land_uses" INNER JOIN "land_uses_photos" ON "land_uses".id = "land_uses_photos".land_use_id WHERE ("land_uses_photos".photo_id = 1 ) ORDER BY "land_uses"."display_order" ASC
Rendered photos/_photo_tiles.html.haml (204.2ms)
SQL (0.3ms) SELECT COUNT(DISTINCT "photos"."id") FROM "photos" LEFT OUTER JOIN "attachments" ON "attachments"."photo_id" = "photos"."id" LEFT OUTER JOIN "collections" ON "collections"."id" = "photos"."collection_id" WHERE "photos"."collection_id" IS NULL AND "photos"."context_id" IN (6)
Rendered shared/_feedback.html.haml (1.3ms)
Role Load (0.4ms) SELECT "roles".* FROM "roles" INNER JOIN "roles_users" ON "roles".id = "roles_users".role_id WHERE "roles"."name" = 'admin' AND ("roles_users".user_id = 1 ) LIMIT 1
CACHE (0.0ms) SELECT "profiles".* FROM "profiles" WHERE ("profiles".user_id = 1) LIMIT 1
CACHE (0.0ms) SELECT "roles".* FROM "roles" INNER JOIN "roles_users" ON "roles".id = "roles_users".role_id WHERE "roles"."name" = 'admin' AND ("roles_users".user_id = 1 ) LIMIT 1
Rendered shared/_menu.html.haml (35.5ms)
Rendered shared/_footer.html.haml (2.9ms)
Rendered photos/index.html.haml within layouts/application (729.3ms)
Completed 200 OK in 990ms (Views: 728.5ms | ActiveRecord: 7.7ms)
For the second page of a search (shows no results even though they exist):
Started GET "/photos?commit=Search&page=2&search[context_id_in][]=6&search[near][]=&search[near][]=100&search[tagged_with]=&search[text_contains]=&utf8=%E2%9C%93" for 127.0.0.1 at 2011-04-28 12:01:33 -0500
Processing by PhotosController#index as HTML
Parameters: {"commit"=>"Search", "page"=>"2", "search"=>{"context_id_in"=>["6"], "near"=>["", "100"], "tagged_with"=>"", "text_contains"=>""}, "utf8"=>"✓"}
SQL (0.4ms) SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
SQL (0.3ms) SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
User Load (0.7ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
Context Load (0.3ms) SELECT "contexts".* FROM "contexts" ORDER BY "contexts"."display_order" ASC
Focus Load (0.3ms) SELECT "focus".* FROM "focus" ORDER BY "focus"."display_order" ASC
LandUse Load (0.3ms) SELECT "land_uses".* FROM "land_uses" ORDER BY "land_uses"."display_order" ASC
Rendered static/_help-context.html.haml (4.9ms)
Rendered static/_help-focus.html.haml (3.4ms)
Rendered photos/_search.html.haml (307.8ms)
SQL (0.3ms) SELECT COUNT(DISTINCT "photos"."id") FROM "photos" LEFT OUTER JOIN "attachments" ON "attachments"."photo_id" = "photos"."id" LEFT OUTER JOIN "collections" ON "collections"."id" = "photos"."collection_id" WHERE "photos"."collection_id" IS NULL AND "photos"."context_id" IN (6) LIMIT 1 OFFSET 1
SQL (0.3ms) SELECT COUNT(DISTINCT "photos"."id") FROM "photos" LEFT OUTER JOIN "attachments" ON "attachments"."photo_id" = "photos"."id" LEFT OUTER JOIN "collections" ON "collections"."id" = "photos"."collection_id" WHERE "photos"."collection_id" IS NULL AND "photos"."context_id" IN (6)
Rendered shared/_feedback.html.haml (1.5ms)
Role Load (0.4ms) SELECT "roles".* FROM "roles" INNER JOIN "roles_users" ON "roles".id = "roles_users".role_id WHERE "roles"."name" = 'admin' AND ("roles_users".user_id = 1 ) LIMIT 1
Profile Load (1.6ms) SELECT "profiles".* FROM "profiles" WHERE ("profiles".user_id = 1) LIMIT 1
CACHE (0.0ms) SELECT "roles".* FROM "roles" INNER JOIN "roles_users" ON "roles".id = "roles_users".role_id WHERE "roles"."name" = 'admin' AND ("roles_users".user_id = 1 ) LIMIT 1
Rendered shared/_menu.html.haml (209.5ms)
Rendered shared/_footer.html.haml (2.7ms)
Rendered photos/index.html.haml within layouts/application (822.3ms)
Completed 200 OK in 934ms (Views: 823.7ms | ActiveRecord: 5.1ms)
Again note that in the logs above I have set pagination to 1 per page so I can see if the paginator is showing the right number of results, and it is. For instance, if I search for something I know there are 3 matches for at one per page the paginator says there are three pages of results, however pages 2 and 3 are blank.
I am completely stumped, any help would be much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试添加您的范围作为搜索方法。
我自己不使用 kaminari,所以我不能肯定地说,但我知道 MetaSearch 文档说使用 search_methods 以便在搜索中使用范围。
Try adding your scope as a search method.
I don't use kaminari myself so I can't say for sure, but I know that the MetaSearch docs say to use search_methods in order to use scopes in searches.
它适用于我当前最新的 gems(meta_search 1.0.4,kaminari 0.12.4)。
作为 Kaminari gem 的作者,我认为某些旧版本的 Kaminari 可能无法与 meta_search 一起使用。我实际上修复了几个可能导致此类问题的错误。
那么,您可以升级您的 Kaminari 宝石并重试吗?
it works for me with the current latest gems (meta_search 1.0.4, kaminari 0.12.4).
As the author of Kaminari gem, I suppose some older versions of Kaminari possibly does not work with meta_search. I actually fixed several bugs that may cause this kind of problem.
So, can you please upgrade your Kaminari gem and try again?