-
Notifications
You must be signed in to change notification settings - Fork 236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rails-jquery-autocomplete with Cells - undefined method `rewrite_autocomplete_option' #426
Comments
It's simple, you have to find the helper module that defines this method and include it in the cell. Please also update to 4.1. |
Hey, def rewrite_autocomplete_option(options)
options["data-autocomplete-fields"] = JSON.generate(options.delete :fields) if options[:fields]
options["data-update-elements"] = JSON.generate(options.delete :update_elements) if options[:update_elements]
options["data-id-element"] = options.delete :id_element if options[:id_element]
options["data-append-to"] = options.delete :append_to if options[:append_to]
options
end I also wrote my own form helper on top of that # Produces an autocomplete field that can populate an id element
# = Params
# +association+ - symbol for the association
# +path+ - url used for getting autocompletion results
# = Options
# +:autocomplete+ - default to false (the html_option autocompletes from previous output)
# +:id_element+ - change the populated id field, or set to nil to do nothing
def autocomplete_association(f, association, path, options={})
# Da magic regexp
id_element = "##{f.object_name}[#{association.to_s}_id]".gsub(/(\])?\[/, "_").chop
options[:autocomplete] ||= false
options[:id_element] ||= id_element
capture do
concat f.hidden_field("#{association.to_s}_id")
concat f.autocomplete_field(association, path, options)
end
end So then I could call the autocompleter easily in my views
...which would fill both the field with the visual name for the user, and the hidden id field with the id element for database saving purposes. |
Thank you both for the extremely fast replies! @Startouf thank you for the code snippet, I'm too new to Ruby/Rails to figure this out myself and your code brought me further. In fact, it solved the issue!... ish. I'm now stuck on Cells generating incorrect form elements where input elements are siblings to the form element, as described in #260. I can make a new issue to pursue a solution for this, but I take it you don't have this problem? @apotonick I've experimented with an upgrade but there's a version conflict error when I just target |
@gaggle The new issue you raised seem to concern only HAML but I am using ERB. No problems here anyways. Don't forget to include cells-rails (Cells hacks for Rails) and cells-(Haml/erb) into your Gemfile. Amongst others, I have
inside cells that need forms |
@Startouf I see, I didn't know it just affected HAML, that is indeed what we use. I've been unable to include There's probably some way through all this that I don't know about yet, but unless you're spotting something obvious I don't mean to drag you into debugging our setup. For now I'll park my Cells branch and loop back to this when I can upgrade with confidence. |
@gaggle The "upgrade" to 4.1 should be seamless, you only need to bump up I really encourage you to stay up-to-date! Jump on our Gitter channel for quick support. https://gitter.im/trailblazer/chat |
@apotonick, thanks I'll check out the gitter channel. When I add version constraint and
Then doing a
Is Cells supposed to work with Rails 3.2? Because I assumed this is on us, that we need to get with the times. |
It should work with 3.2 - I actually don't know about the Tilt compat, but you could try setting the cells tilt dependency to 1.1, this should still work. |
Hi @apotonick, I plucked away at this, and have managed some progress but ultimately no success. To recap, I downloaded the
But the result is the same as my previous attempt, pages that uses widgets raise a The locally-altered-hack is not sustainable in the long run anyway, so I'll be backing out of this and phasing out our use of |
@gaggle Can you show me one of those "missing constant" exceptions and the way you invoke the |
Closing as I have stopped using Rails. |
Good decision. 😉 |
Hi,
I'd like to use Cells, but run into problems with forms. I've overwritten
dom_class
/dom_id
but I also want to use therails-jquery-autocomplete
gem in my form. But I get this error:@Startouf already made an issue @ risuiowa/rails-jquery-autocomplete#58 in the autocomplete repo, but I wanted to create one here as well to see if someone knows of a workaround.
(currently on Rails 3.2, cells 4.0.5)
The text was updated successfully, but these errors were encountered: