Created
May 7, 2012 20:28
-
-
Save tiegz/2630194 to your computer and use it in GitHub Desktop.
Visualizing ARel ASTs from your ActiveRecord queries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add the graphiz gem to your Gemfile | |
gem "ruby-graphviz" | |
# And in the rails console, try the following: | |
require 'graphviz' | |
arel = User.where(:name => "Sadako Yamamura").where(:location => "Tokyo").limit(1).arel | |
graph = GraphViz.parse_string(arel.to_dot) | |
graph.output(:png => "user_query.png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment