Hi,

We happened to need #find_by_sql today and noticed that it appears to have 
a somewhat confusing interface/method definition/documentation.

The method definition is:

def find_by_sql(sql, binds = [])
>   # ...
> end


Which would seem to imply that you should use it like this:

Post.find_by_sql("SELECT * FROM posts WHERE id = ?", [1])


However, that is wrong, you actually need to do (and the examples in the 
documentation are like this):

Post.find_by_sql(["SELECT * FROM posts WHERE id = ?", 1])


I spent some time reading the documentation and code and can't figure out 
what the binds argument should be used for.

Maybe some sort of example or explanation should be added to the 
#find_by_sql documentation? I'd do so myself, but I'm having trouble 
figuring it out…


— Matias

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to