# Named scope help

**URL:** <https://www.ruby-forum.com/t/named-scope-help/179610>\
**Category:** Rails\
**Created:** [November 30, 2009, 12:18pm UTC](https://www.ruby-forum.com/t/named-scope-help/179610 "2009-11-30T12:18:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmaenpaa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de053/32.png) [@jmaenpaa](https://www.ruby-forum.com/u/jmaenpaa)\
**Post date:** [November 30, 2009, 12:18pm UTC](https://www.ruby-forum.com/t/named-scope-help/179610/1 "2009-11-30T12:18:05Z")

</div>

Hi guys i am trying to figure out a named scope for Time.now I have this  
so far in my application model

named\_scope :on\_time, lambda { |time| {  
:conditions =\> [’(time = ?)’, Time.now] } }

then i will call it by using on\_time but i get an undefined error  
message

---

<div class="post-metadata">

**Author:** ![jmaenpaa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de053/32.png) [@jmaenpaa](https://www.ruby-forum.com/u/jmaenpaa)\
**Post date:** [December 1, 2009, 5:15am UTC](https://www.ruby-forum.com/t/named-scope-help/179610/2 "2009-12-01T05:15:52Z")

</div>

Hi John M.

```
 Can you please tell how you call this named scope and what the 

```

error trace says?

Sijo

---

<div class="post-metadata">

**Author:** ![jmaenpaa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de053/32.png) [@jmaenpaa](https://www.ruby-forum.com/u/jmaenpaa)\
**Post date:** [December 1, 2009, 6:49am UTC](https://www.ruby-forum.com/t/named-scope-help/179610/3 "2009-12-01T06:49:21Z")

</div>

John M. wrote:

> Hi guys i am trying to figure out a named scope for Time.now I have this  
> so far in my application model
> 
> named\_scope :on\_time, lambda { |time| {  
> :conditions =\> [‘(time = ?)’, Time.now] } }
> 
> then i will call it by using on\_time but i get an undefined error  
> message

You’re not using the block argument |time|-- why do you have it? And  
why are you using the array syntax for :conditions when the hash syntax  
would be better?

Best,  
–Â  
MarnenÂ Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid
