No superclass method `get_autocomplete_items'
denispeplin opened this issue · 6 comments
I'm using customisation by overriding get_autocomplete_items
in a controller, the method described here: http://stackoverflow.com/questions/18716999/customize-list-from-rails3-jquery-autocomplete
But with Rails 3.2.19 and rails3-jquery-autocomplete 1.0.14 I'm getting this error:
NoMethodError - super: no superclass method `get_autocomplete_items'
Checked with 1.0.11 version, it still works. Haven't checked intermediate versions.
Can you point to master and check if it works there; I had to back out a pull request that was breaking some existing functionality. It may address this issue. If that does not work, please let me know also what release of Ruby this occurring on and I'll try to reproduce.
Checked out master, got same error.
# ruby -v
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux-gnu]
@denispeplin just following up since it's been a few days. Should get this addressed early part of next week; Monday or Tuesday.
No worry, for now I'm happy with rails3-jquery-autocomplete 1.0.11 :)
Well, I tried to use autocomplete with another model, but found, that version 1.0.11 can break JSON output, when model described in ActiveModel::Serializer.
This issue can be solved with version 1.0.14, by using block in controllers definition, but I had to find a workaround for the issue with overriding get_autocomplete_items
method.
In sources I found, that it now being defined dynamically, so it no longer can be called with super
. But it just calls underlying ORM method. So I changed code in example from link above:
def get_autocomplete_items(parameters)
items = super(parameters)
items = items.where(searchable: true)
end
to this:
def get_autocomplete_items(parameters)
items = active_record_get_autocomplete_items(parameters)
items = items.where(searchable: true)
end
and now it works fine for AcriveRecord ORM.
Gotcha; I glanced at the stack overflow answer and didn't think to much about the fact they are calling super. That wouldn't work anymore. I'll post an update on the Stack Overflow question for the future since that has pretty high SEO. I can see why you would to do that to get the other settings as they are defaulted in the gem; typically when I override get_autocomplete_items I don't end up calling up the chain because I'm overriding everything.