Rails Tips – Counter Cache (.size vs .count)

* Size (rails function) is more intelligent than count (ruby function) * Notice that when you counter cache, size makes only one call to db as opposed to count which does 2 queries. 1.9.2-p320 :057 > ParentModel.find(5765).childmodel.count RequestedTrip Load (0.3ms) SELECT `parent_models`.* FROM `parent_models` WHERE (`parent_models`.`id` = 5765) ORDER BY parent_models.created_at desc LIMIT 1 SQL […]

Continue reading


Virtual Touring in Google Maps with Play/Pause feature

Source code and sample html available at: https://github.com/prabgupt/googleMap_virtual_tour Usage: Mentioned in README present at git repo above Purpose of Plugin: You can display virtual tours between places on map. Currently, above sample show animation of marker moving along actual direction path between places located on map in sequence specified. Prequisite HTML, jQuery/JavaScript knowledge is required Basic […]

Continue reading


AutoCompletion script for world places using google geocode API

Source code and README available at: https://github.com/prabgupt/geocode_autocompletion_js Purpose of this Utility: It will auto suggest world places based on user input Instructions  as well as sample HTML to use the code are mentioned inside README mentioned above. Making of geocode_autocomplete.js I’m assuming here that you are already familiar with JavaScript/jQuery. You’ll need to understand following things […]

Continue reading