Is there any tool to convet ActiveRecord 2.3.5 statement to sql

36 views
Skip to first unread message

nyt1972

unread,
Apr 14, 2018, 2:22:46 AM4/14/18
to Ruby on Rails: Talk
Hello,

I want to ask Is there any tool to convet ActiveRecord 2.3.5 statement to sql?

kaine wright

unread,
Apr 14, 2018, 6:42:43 AM4/14/18
to Ruby on Rails: Talk
This may help http://guides.rubyonrails.org/v2.3.11/active_record_querying.html

what is it you are trying to convert. Do you mean you wish to add a column to your database to store information if so you would use your model and migrations

Hassan Schroeder

unread,
Apr 14, 2018, 10:13:15 AM4/14/18
to rubyonrails-talk
On Fri, Apr 13, 2018 at 10:13 PM, nyt1972 <nyt...@gmail.com> wrote:

> I want to ask Is there any tool to convet ActiveRecord 2.3.5 statement to
> sql?

If it's a one-time or occasional thing, just execute the statement
and grab the query SQL from your logs.

There are also `to_sql()` methods in ActiveRecord::Relation and
ActiveRecord::ConnectionAdapters::DatabaseStatements which
(hint) you could find by searching the docs.

HTH,
--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
twitter: @hassan
Consulting Availability : Silicon Valley or remote

snappa

unread,
Apr 14, 2018, 10:17:12 AM4/14/18
to Ruby on Rails: Talk
Should be able to see the SQL in the debug log if you have it enabled.

tonypm

unread,
Apr 19, 2018, 4:36:09 AM4/19/18
to Ruby on Rails: Talk
For ActiveRecord in Rails 2.3, you can use 

.construct_finder_sql({})

tonypm
Reply all
Reply to author
Forward
0 new messages