1

I've seen somewhere but can not remember. How to get a SQL string from an ActiveRecord object?

Client.find(1).to_sql_string

2 Answers 2

3

In Rails 3 you can use to_sql method

Client.first.to_sql
#=> some raw sql
Sign up to request clarification or add additional context in comments.

Comments

1

I think you where looking at arel, which has a nice to_sql

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.