Working around a SQL Injection Vulnerability in Ruby on Rails (CVE-2012-5664)

Quoting [Aaron Patterson from the Rails Security mailing list](https://groups.google.com/forum/?fromgroups=&buffer_share=f30b8&utm_source=buffer#!topic/rubyonrails-security/DCNTNp_qjFM):

> There is a SQL injection vulnerability in Active Record in ALL versions. This vulnerability has been assigned the CVE identifier CVE-2012-5664. 
> 
> Versions Affected:  All. 
> Not affected:       NONE. 
> Fixed Versions:     3.2.10, 3.1.9, 3.0.18 
> 
> Impact 
> ------ 
> Due to the way dynamic finders in Active Record extract options from method parameters, a method parameter can mistakenly be used as a scope.  Carefully crafted requests can use the scope to inject arbitrary SQL. 
> 
> All users running an affected release should either upgrade or use one of the work arounds immediately. 
> 
> Impacted code passes user provided data to a dynamic finder like this: 
> 
>   Post.find_by_id(params[:id]) 
> 
> Releases 
> -------- 
> The  3.2.10, 3.1.9 & 3.0.18 releases are available at the normal locations. 
> 
> Workarounds 
> ----------- 
> The issue can be mitigated by explicitly converting the parameter to an expected value.  For example, change this: 
> 
>   Post.find_by_id(params[:id]) 
> 
> to this: 
> 
>   Post.find_by_id(params[:id].to_s) 

My rationale for the workaround was that it does not hurt to have it there, and it might save several users who can't upgrade their Rails versions (for incompatibility reasons for example), but can easily upgrade Cancan.