Method "first" of a model

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.

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

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs