Ask A Question

Notifications

You’re not receiving notifications from this thread.

How do I ajax query (select) on a huge number of records (zipcodes)?

Brandon Buteaux asked in Javascript
Spaces-are-not-working-in-wysiwyg-editor-but-the-question-from-above.
Reply
Hmm, spaces are working for me. Your post looks like you were in the code mode though.

You'll need an autocomplete or select library and then you'll need a JSON endpoint to gather the filtered records from. I did an episode on autocomplete here: https://gorails.com/episodes/global-autocomplete-search and I covered Selectize here: https://gorails.com/episodes/select-or-create-with-selectize-js

Selectize has an option for "remote data loading" as they call it. They have a couple demos at the bottom here that use Github and Rotten Tomatoes APIs. https://selectize.github.io/selectize.js/
Reply
Spaces are working from my macbook on chrome and firefox.  However, on my windows 10 machine on the newest version of chrome spaces still are not working for some reason - that is just an fyi.

Thanks for your quick response and I realized the JS and endpoints - I also will go look at the selectize video of yours.  I did not know if there is a best practices or like they call it "Rails Way or Railsy" of doing it.  I come from C# and Python and those two languages are pretty explicit in ways to do things - I am trying to get used to Rails/Ruby and their being multiple proper ways to do things, haha.
Reply
I'll have to boot into Windows and see if I can replicate that. What a weird problem. I'm also possibly going to swap out Trix editor anyways because it's not the best for syntax highlighting.

There isn't really a Rails way of doing things because Rails refuses to get too involved in the client side JS. I came from Python before I started Ruby and had the same sort of struggle. It's not common to have a whole bunch of options to tackle things in other communities!
Reply
You are pretty awesome.  Thanks for the great work you do - and you are correct about other communities - i.e. "This is the WAY to do x, any other way is inefficient or incorrect" is pretty much what one gets most of the time.
Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 86,140+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.