How to override 'where' in rails 3
Posted
by
Zakwan Alhajjar
on Stack Overflow
See other posts from Stack Overflow
or by Zakwan Alhajjar
Published on 2011-01-09T11:29:04Z
Indexed on
2011/01/09
11:53 UTC
Read the original article
Hit count: 103
I have upgraded my application from rails 2.3.8 to 3.0.3 . But I'm facing a problem. I was using 'find' but the overriding doesn't work in rails 3:
# override activerecord's find to allow us to find by name or id transparently
def self.find(*args)
if args.is_a?(Array) and args.first.is_a?(String) and (args.first.index(/[a-zA-Z\-_]+/) or args.first.to_i.eql?(0) )
find_by_login_slug(args)
else
super
end
end
I'm wondering if there is a way to make this work in rails 3 or even by using where instead.
thanks
© Stack Overflow or respective owner