【发布时间】:2011-02-10 11:03:21
【问题描述】:
最近我开始使用https://github.com/crowdint/rails3-jquery-autocomplete
效果很好,但我试图为我正在自动完成的结果设置一个范围,在这个问题中我得到了一个很好的答案:Scoping the results for rails3 jquery autocomplete plugin
使用 Claudio 的代码,我已经成功地确定了范围:
class PostsController < ApplicationController
autocomplete :post, :title
def get_items(parameters)
Post.where(:user_id => current_user.id)
end
这是因为我覆盖了插件的 get_items 方法。你可以在这里看到:https://github.com/crowdint/rails3-jquery-autocomplete/commit/b3c18ac92ced2932ac6e9d17237343b512d2144d#L1R84(我在这次提交之前有一个版本,所以 get_items 仍然适用于我)。
我的范围的问题是自动完成功能不再起作用。当该人开始输入时,get_items 中指定的列表只会弹出,而不是从该列表中建议的项目。
我假设我的覆盖方法有问题。有什么想法吗?
最好, 艾略特
【问题讨论】:
标签: ruby-on-rails ruby ruby-on-rails-3 jquery-autocomplete