From 06b8936914bfbce092be72692d3fe2a4ff3bbe96 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 19 Feb 2005 11:30:38 +0000 Subject: Fixed that find_by_* would fail when column names had numbers #670 [demetrius] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@681 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/CHANGELOG | 2 ++ activerecord/lib/active_record/base.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index cc906713be..fddfb5ef0b 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fixed that find_by_* would fail when column names had numbers #670 [demetrius] + * Fixed the SQL Server adapter on a bunch of issues #667 [DeLynn] 1. Created a new columns method that is much cleaner. diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 226db25ea3..e00f0d31bc 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -750,7 +750,7 @@ module ActiveRecord #:nodoc: def method_missing(method_id, *arguments) method_name = method_id.id2name - if method_name =~ /find_(all_by|by)_([_a-z]+)/ + if method_name =~ /find_(all_by|by)_([_a-z][_a-z\d]*)/ finder, attributes = ($1 == "all_by" ? :find_all : :find_first), $2.split("_and_") attributes.each { |attr_name| super unless column_methods_hash[attr_name.intern] } -- cgit v1.2.3