4 ms·
For anybody on Rails, you can call .to_sql on any ActiveRecord::Relation and it will return the exact SQL string that your code is producing. Really handy for t
by vinceguidry 9y ago
For anybody on Rails, you can call .to_sql on any ActiveRecord::Relation and it will return the exact SQL string that your code is producing. Really handy for troubleshooting, especially for associations.
- meditationapp 9y agoOf course, not all operations return a relation, such as count, update_all, delete, etc, even if they have a sql equivalent.