1. Saving files to a directory that is not shared between deploys or servers If you save your uploads to...

This card shows how to upgrade a Rails 2 application from Rails 2.3.8 through every single patch level up to...

Active Record's select method allows you to make use of the power of MySQL select statements. On the one...

Merge requests are often rejected for similar reasons. To avoid this, before you send a merge request, please confirm that...

You have multiple options: Just don't have a type column. All STI magic will be disabled automatically.

When you need to find out in which kind of spec you are during run-time, it's definitely possible...

ActiveRecord translations live in locale.activerecord. ActiveModel translations live in locale.activemodel. To use the same translations for both, use YAML references...

wikihow.com

Issue this command: sqlite3 ~/Library/Application\ Support/Dock/*.db "DELETE from apps WHERE title='APP_NAME';" && killall Dock This tells sqlite3 to...

This trick might be useful to implement more complicated directives in AngularJS. I needed it to do drag'n'drop...

Authentication is hard: there are many edge cases, and most users (including yourself) usually only go the "happy path" once...

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

highscalability.com

Awesome battle report from Pinterest trying to scale their setup using different approaches. When you push something to the limit...

makandra dev
github.com

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

apidock.com

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

stackoverflow.com

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

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

makandra dev

Ever wondered about the difference between def and define_method? Turns out there are three implicit contexts in Ruby. def...