> You need to have a deeper understanding of ruby, and specifically the magic > of the splat (*) operator.
I think you missed that the method signature is `def find_by_sql(sql, binds = [])`, and not `def find_by_sql(sql, *binds)`. There’s no splat in the method signature. Before trying to belittle someone, maybe make sure that you’re actually correct :P Remember MINSWAN, people. (As for the on-topic conversation, sorry, I have no idea what’s going on with that `binds` argument.) Cheers, -foca On Thu, Jun 25, 2015 at 2:38 PM, Matias Korhonen <[email protected]> wrote: > 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 [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/rubyonrails-core. > For more options, visit https://groups.google.com/d/optout. -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.
