TL;DR: You should generally use #size to count associated records. size Counts already loaded elements If the association is...
tl;dr: Do not use merge! for session hashes. Use update instead. Outline Let's assume you're modifying the...
Watch out when saying something like 1.year in Rails. The result is not a Fixnum and can cause unexpected errors...
MongoMapper is a MongoDB adapter for Ruby. We've forked it so it works for Rails 2.3.x applications running...
See attached link for a way to extract the conditions of a named scope in Rails 2.3.
Rails 2.3.16+ on Ruby 1.9 causes warnings like this: .../gems/activesupport-2.3.17/lib/active_support/core_ext/string/output_safety.rb:22: warning: regexp match /.../n against to UTF-8 string...
JavaScripts and CSS should be minified for production use. In Rails 3.1+ the asset pipeline will take care of this...
If you need to capture signatures on an IPad or similar device, you can use Thomas J Bradley's excellent...
You either have an old version of Mocha and an edge version of Rails 3.2, or you have a new...
This page lists many query methods and options in ActiveRecord which do not sanitize raw SQL arguments and are not...
Stringex is a gem that offers some extensions to Ruby's String class. Ruby 1.9 compatible, and knows its way...
RVM needs to be updated regularly to know of Ruby versions released since installation (or last update).
If bundle install shows the following message for you ... Error Bundler::HTTPError during request to dependency API ... upgrade to Bundler...
In our continued quest to extract proven code snippets from makandropedia into tested and upgradable gems, we have released Edge...
TLDR: Ruby class variables (@@foo) are dangerous in many ways. You should avoid them at all cost. See bottom of...
Ruby has two different ways to match the start and the end of a text: ^ (Start of line) and $ (End...
January has been a very bad month for Ruby on Rails developers, with two high-severity security bugs permitting remote...
If you have an integer and want to use it to represent an element's position (like "1st" for 1...
validates_uniqueness_of is not sufficient to ensure the uniqueness of a value. The reason for this is that in...
Calling bundle update GEMNAME will update a lot more gems than you think. E.g. when you do this...
Calling bundle update (without arguments) updates all your gems at once. Given that many gems don't care about stable...
Apache HTTP server benchmarking tool (ab) is a nice tool to test performance on sites delivered by HTTP. If the...
Use Socket.gethostname. So for a machine whose hostname is "happycat", it will look like this: >> Socket.gethostname => "happycat" That should work...
Upgrade the offending gem. If you cannot or don't want to upgrade, lock rake to 0.8.7.