Skip to content
 

Rails Warning Fail

Recent versions of rails 3 have started spitting out a new deprecation warning:

String-based interpolation of association conditions is deprecated. Please use a proc instead. So, for example, has_many :older_friends, :conditions => ‘age > #{age}’ should be changed to has_many :older_friends, :conditions => proc { “age > #{age}” }.

Now call me confused if you like, but isn’t the suggested replacement still doing just as much string interpolation as the original?

One Comment

  1. Robin says:

    Try the following:

    :conditions => proc { ["age > ?", age] }

Leave a Reply