最近,我开始使用https://github.com/crowdint/rails3-jquery-autocomplete修改方法,并利用PARAMS
它的伟大工程,但我想设置为我autocompleteing结果的范围,在这个问题上我有一个很好的答案:Scoping the results for rails3 jquery autocomplete plugin
使用克劳迪奥的代码,我已经成功地作用域为这样:
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中指定的列表,而不是从该列表中建议的项目。
我假设我正在做我的覆盖方法有问题。有任何想法吗?
最佳, 埃利奥特
谢谢你!我一回家就会试试这个! – Elliot 2011-02-03 21:18:23