On 9 October 2010 00:44, Luke Cowell <[email protected]> wrote:
> Sometimes if I need to do a calculation before I call a named scope or if I 
> want to make a different query based on the input, I do something like this:
>
> class Media < AR:Base
>  def dvds(name = "")
>    if name.blank?
>      Media.scoped({})
>    else
>      name.downcase!
>      Media.scoped(:conditions => {:name => name})
>    end
>  end
> end

Could that just be
Media.scoped( :conditions => {:name => name.downcase!} unless name.blank? )
or something similar, I have not tried it.

Colin

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to