# How would you know how to call this rails method (select\_all) this starting point of it's Rails API

**URL:** <https://www.ruby-forum.com/t/how-would-you-know-how-to-call-this-rails-method-select-all-this-starting-point-of-its-rails-api/150733>\
**Category:** Rails\
**Created:** [October 12, 2008, 8:09am UTC](https://www.ruby-forum.com/t/how-would-you-know-how-to-call-this-rails-method-select-all-this-starting-point-of-its-rails-api/150733 "2008-10-12T08:09:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [October 12, 2008, 8:09am UTC](https://www.ruby-forum.com/t/how-would-you-know-how-to-call-this-rails-method-select-all-this-starting-point-of-its-rails-api/150733/1 "2008-10-12T08:09:40Z")

</div>

Hi,  
I’m curious. If you saw the Rails “select\_all(sql, name = nil)” method  
(rerfer  
[ActiveRecord::ConnectionAdapters::DatabaseStatements](http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/DatabaseStatements.html#M001060)),  
and wanted to use it, how would you really know how to use it and call  
it  
from this API doco?

I know from googling that you can call it from within a model by going  
“ActiveRecord::Base.connection.select\_all(sql\_string)”, but how would I  
have  
worked this out from the API doco. Within the API page for the method  
it  
says it’s within Module  
“ActiveRecord::ConnectionAdapters::DatabaseStatements”.

Thanks

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [October 12, 2008, 12:00pm UTC](https://www.ruby-forum.com/t/how-would-you-know-how-to-call-this-rails-method-select-all-this-starting-point-of-its-rails-api/150733/2 "2008-10-12T12:00:42Z")

</div>

On Oct 12, 7:09 am, “Greg H.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hi,  
> I’m curious. If you saw the Rails “select\_all(sql, name = nil)” method  
> (rerferhttp://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/Da…),  
> and wanted to use it, how would you really know how to use it and call  
> it  
> from this API doco?
> 
> I know from googling that you can call it from within a model by going  
> “ActiveRecord::Base.connection.select\_all(sql\_string)”, but how would I have  
> worked this out from the API doco.

That’s just me, but it seems kind of obvious to me. The second  
parameter is a bit more mysterious but if it has a default value  
chances are you can just ignore it. the fact that the first parameter  
is called sql strongly implies that you should give it some sql.

Fred

> Within the API page for the method it  
> says it’s within Module

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [October 13, 2008, 12:38am UTC](https://www.ruby-forum.com/t/how-would-you-know-how-to-call-this-rails-method-select-all-this-starting-point-of-its-rails-api/150733/3 "2008-10-13T00:38:52Z")

</div>

how is it obvious to your Frederick can I ask - how would you know these  
methods will end up where they do - I’m guessing (but might be wrong)  
you  
would have to look through Rails code to find out how it uses/mixes in  
the  
methods as the framework instantiates itself. If I’m correct here this  
would be normal its not obvious to see how you would call the method…  
Am I on the right track here?

On Sun, Oct 12, 2008 at 7:59 PM, Frederick C. \<

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [October 13, 2008, 9:40am UTC](https://www.ruby-forum.com/t/how-would-you-know-how-to-call-this-rails-method-select-all-this-starting-point-of-its-rails-api/150733/4 "2008-10-13T09:40:40Z")

</div>

On Oct 12, 11:38 pm, “Greg H.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> how is it obvious to your Frederick can I ask - how would you know these  
> methods will end up where they do - I’m guessing (but might be wrong) you  
> would have to look through Rails code to find out how it uses/mixes in the  
> methods as the framework instantiates itself. If I’m correct here this  
> would be normal its not obvious to see how you would call the method…  
> Am I on the right track here?

I suppose there is some prior knowledge or a bit of experimentation to  
know that connection adapters are split up into those various  
modules.

Fred
