Hello, This is probably a silly question but looking at "api.rubyonrails.org", I can''t seem to figure out which method I should be using ... I want to execute an sql statement, like "truncate table BLAH" from within one of my rails app ... What''s the "right" way to do this? Thanks, /B -- Bruno Mattarollo <bruno.mattarollo@gmail.com> Currently in: Sydney, Australia
Hi Bruno, On 11.1.2006, at 8.59, Bruno Mattarollo wrote:> Hello, > > This is probably a silly question but looking at > "api.rubyonrails.org", I can''t seem to figure out which method I > should be using ... I want to execute an sql statement, like "truncate > table BLAH" from within one of my rails app ... What''s the "right" way > to do this?See http://api.rubyonrails.com/classes/ActiveRecord/ ConnectionAdapters/DatabaseStatements.html You''ll want to use the raw db connection, like: SomeModel.connection.execute("your statement") or, if you''re still wanting something in return, SomeModel.connection.select_all("your select statement") //jarkko> > Thanks, > > /B > > -- > Bruno Mattarollo <bruno.mattarollo@gmail.com> > Currently in: Sydney, Australia > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Jarkko Laine http://jlaine.net http://odesign.fi -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2363 bytes Desc: not available Url : http://wrath.rubyonrails.org/pipermail/rails/attachments/20060111/2ded17ac/smime.bin
Thanks Jarkko, I gave that a try and it works fine! Just in time. You always have helpful answers mate. BTW how are you doing? It''s been a while since we met in Copenhagen for that OpenACS/.LRN gathering ... Cheers /B On 1/11/06, Jarkko Laine <jarkko@jlaine.net> wrote:> Hi Bruno, > > On 11.1.2006, at 8.59, Bruno Mattarollo wrote: > > > Hello, > > > > This is probably a silly question but looking at > > "api.rubyonrails.org", I can''t seem to figure out which method I > > should be using ... I want to execute an sql statement, like "truncate > > table BLAH" from within one of my rails app ... What''s the "right" way > > to do this? > > See http://api.rubyonrails.com/classes/ActiveRecord/ > ConnectionAdapters/DatabaseStatements.html > > You''ll want to use the raw db connection, like: > > SomeModel.connection.execute("your statement") > > or, if you''re still wanting something in return, > > SomeModel.connection.select_all("your select statement")-- Bruno Mattarollo <bruno.mattarollo@gmail.com> Currently in: Sydney, Australia