One item in a return list

I have a find_by_sql that returns a list of only one object. What is
the best way to get that object out of the list? Is there a way other
than a for loop?

On 6/20/07, David M. [email protected] wrote:

I have a find_by_sql that returns a list of only one object. What is
the best way to get that object out of the list? Is there a way other
than a for loop?

Use first():

row = Model.find_by_sql(sql).first

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