named_scope and substings
Posted
by Philb28
on Stack Overflow
See other posts from Stack Overflow
or by Philb28
Published on 2010-04-20T11:14:39Z
Indexed on
2010/04/20
11:53 UTC
Read the original article
Hit count: 310
I have a named_scope in rails that finds episodes by there directors given name
named_scope :director_given, lambda { |dr| {:joins => :director, :conditions => ['given = ?', dr]} }
It works great but I would like it to also work on substrings one the name. e.g. instead of having to search for 'Lucy' you could just search 'Lu'.
P.S. I also have another named scope which does exactly the same thing but on the directors last name. It there a way to combine the two?
Thanks,
© Stack Overflow or respective owner