We have often felt the pain where our models need to serve too many masters. E.g. we are adding a...

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...

github.com

When using the json gem, you might run into this error when using JSON.parse: >> json = 'foo'.to_json >> JSON.parse(json...

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...

developer.mozilla.org

Non-SSL contents on SSL pages are blocked by default Bug 834836 – Turn on pref to block mixed active content...

apidock.com

All columns of a model's database table are automagically available through accessors on the Active Record object.

Note: This technique is confusing and slows down your test suite. Copy the attached code to features/support. This gets you...

stackoverflow.com

When you use ab to do some performance benchmarking, you might run into output like this: Complete requests: 200

blog.codeclimate.com

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...

Rails flashes (FlashHash) track a list of used keys, which is not respected when comparing flash hashes.

Do not pass times to date attributes. Always convert times to dates when your application uses time zones. Background

ariejan.net

Rails understands a :limit options when you create columns in a migration. Its meaning depends on the column type, and...

Google Chrome saves your profile data in ~/.config/google-chrome. To transfer the profile to for example a system you have setup...

web.archive.org

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...

mysqlperformanceblog.com

When MySQL refuses to use your index, there's a number of things that you may be doing wrong. One...

If you need to capture signatures on an IPad or similar device, you can use Thomas J Bradley's excellent...

makandra dev
rails-sqli.org

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...

The Edge Rider gem gives your relations a method #traverse_association which returns a new relation by "pivoting" around a...

TLDR: Ruby class variables (@@foo) are dangerous in many ways. You should avoid them at all cost. See bottom of...