Greg Hauptmann
2008-Oct-12 06:09 UTC
how would you know how to call this rails method (select_all) this starting point of it''s Rails API description?
Hi, I''m curious. If you saw the Rails "select_all(sql, name = nil)" method (rerfer 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Oct-12 09:59 UTC
Re: how would you know how to call this rails method (select_all) this starting point of it''s Rails API description?
On Oct 12, 7:09 am, "Greg Hauptmann" <greg.hauptmann.r...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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> "ActiveRecord::ConnectionAdapters::DatabaseStatements". > > Thanks--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Greg Hauptmann
2008-Oct-12 22:38 UTC
Re: how would you know how to call this rails method (select_all) this starting point of it''s Rails API description?
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 Cheung < frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > > On Oct 12, 7:09 am, "Greg Hauptmann" <greg.hauptmann.r...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > 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 > > > > "ActiveRecord::ConnectionAdapters::DatabaseStatements". > > > > Thanks > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Oct-13 07:40 UTC
Re: how would you know how to call this rails method (select_all) this starting point of it''s Rails API description?
On Oct 12, 11:38 pm, "Greg Hauptmann" <greg.hauptmann.r...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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> On Sun, Oct 12, 2008 at 7:59 PM, Frederick Cheung < > > frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > On Oct 12, 7:09 am, "Greg Hauptmann" <greg.hauptmann.r...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > 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 > > > > "ActiveRecord::ConnectionAdapters::DatabaseStatements". > > > > Thanks--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---