In the following example the method update_offices_people_count won't be called when office_id changes, because it...
You can detect city and country from an IP address by using the GeoLite database. This is a flat file...
Awesome battle report from Pinterest trying to scale their setup using different approaches. When you push something to the limit...
jQuery plugin to fire events when user's cursor aims at particular dropdown menu items. For making responsive mega dropdowns...
Rails gives you migrations to change your database schema with simple commands like add_column or update. Unfortunately these commands...
Caution when using .where to exclude records from a scope like this: # Fragile - avoid User.where("id NOT IN (?)", excluded_ids...
In specs, the session never persists but is always a new object for each request. Data put into the session...
All columns of a model's database table are automagically available through accessors on the Active Record object.
TL;DR: Variables not declared using var are stored outside the current scope, most likely in the global scope (which...
Rails has generic error messages you can define in your locale .yml files. You may override those application-wide error...
Rails’ reputation as a relatively secure Web framework is well deserved. Out-of-the-box, there is protection against many...
Sometimes you might want to limit the number of associated records in a has_many association, but cannot add a...
Ever wondered about the difference between def and define_method? Turns out there are three implicit contexts in Ruby. def...
The following code doesn't work like expected: page.find(css_selector).find(other_css_selector) The second .find will search...
Great look at the tradeoffs between progressive enhancement with jQuery or similiar, vs. client-side views.
Do not pass times to date attributes. Always convert times to dates when your application uses time zones. Background
Rails understands a :limit options when you create columns in a migration. Its meaning depends on the column type, and...
TL;DR: You should generally use #size to count associated records. size Counts already loaded elements If the association is...
Here is a hacky way to load dumps directly from the source server, without fully copying them over and extracting...
When MySQL refuses to use your index, there's a number of things that you may be doing wrong. One...
See attached link for a way to extract the conditions of a named scope in Rails 2.3.
If you need to capture signatures on an IPad or similar device, you can use Thomas J Bradley's excellent...
This page lists many query methods and options in ActiveRecord which do not sanitize raw SQL arguments and are not...
In our continued quest to extract proven code snippets from makandropedia into tested and upgradable gems, we have released Edge...