# Method "first" of a model

**URL:** <https://www.ruby-forum.com/t/method-first-of-a-model/143508>\
**Category:** Rails\
**Created:** [July 19, 2008, 7:49pm UTC](https://www.ruby-forum.com/t/method-first-of-a-model/143508 "2008-07-19T19:49:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![micktaiwan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4af34b/32.png) [@micktaiwan](https://www.ruby-forum.com/u/micktaiwan)\
**Post date:** [July 19, 2008, 7:49pm UTC](https://www.ruby-forum.com/t/method-first-of-a-model/143508/1 "2008-07-19T19:49:41Z")

</div>

I can 't explain this:

Loading development environment (Rails 2.1.0)

> > t = Task.first(“id=?”,2032)  
> > =\> #\<Task id: 95, project\_id: 9, user\_id: 7, …\>

Can you ?

Mickael.

---

<div class="post-metadata">

**Author:** ![micktaiwan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4af34b/32.png) [@micktaiwan](https://www.ruby-forum.com/u/micktaiwan)\
**Post date:** [July 19, 2008, 8:01pm UTC](https://www.ruby-forum.com/t/method-first-of-a-model/143508/2 "2008-07-19T20:01:56Z")

</div>

On 19 Jul 2008, at 18:49, Mickael Faivre-Macon wrote:

> I can 't explain this:
> 
> Loading development environment (Rails 2.1.0)
> 
> > > t = Task.first(“id=?”,2032)  
> > > =\> #\<Task id: 95, project\_id: 9, user\_id: 7, …\>
> 
> Can you ?

find (and thus the first method) ignores arguments that are not part  
of an option hash, so

t = Task.first(“id=?”,2032) is the same as t = Task.first  
Task.first :conditions =\> [“id=?”,2032]  
does what you want.

Fred

---

<div class="post-metadata">

**Author:** ![micktaiwan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4af34b/32.png) [@micktaiwan](https://www.ruby-forum.com/u/micktaiwan)\
**Post date:** [July 19, 2008, 8:26pm UTC](https://www.ruby-forum.com/t/method-first-of-a-model/143508/3 "2008-07-19T20:26:38Z")

</div>

thanks again Fred !

Frederick C. wrote:

> find (and thus the first method) ignores arguments that are not part  
> of an option hash, so
> 
> t = Task.first(“id=?”,2032) is the same as t = Task.first  
> Task.first :conditions =\> [“id=?”,2032]  
> does what you want.
> 
> Fred
