我正在使用
https://github.com/crowdint/rails3-jquery-autocomplete,它似乎正在工作.唯一的问题是让我说我有一个字段在所有帖子标题上执行自动完成,但我希望它只显示用户创建的帖子的标题.
有没有办法做这样的事情?即一个find_by还是什么?
谢谢!
-Elliot
编辑
它在文档中说:
If you want to display a different version of what you're looking for,you can use the :display_value option. This options receives a method name as the parameter,and that method will be called on the instance when displaying the results. class Brand < ActiveRecord::Base def funky_method "#{self.name}.camelize" end end class ProductsController < Admin::BaseController autocomplete :brand,:name,:display_value => :funky_method end In the example above,you will search by name,but the autocomplete list will display the result of funky_method
我觉得这可以用来做我想要完成的事情,但我不知道从哪里开始?