Created
October 12, 2010 06:30
-
-
Save freshtonic/621759 to your computer and use it in GitHub Desktop.
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
# See what a 'refactored' page looked like before you fucked it up | |
In your Rails/Sinatra/Whatever app when running in your development environment, expose a 'commit' parameter. | |
If that parameter is present, have your app serve the view as it was at that commit. E.G. http://localhost:3000/session/new&_commit=HEAD^. | |
You'll need to intercept whatever you need to in order to determine the file to render (dependent on framework), but ultimately you just need a call to Git like this to make it work: | |
`git show #{params['_commit']}:#{path_to_view} > #{tmp_file}` | |
Then arrange for temp_file to handle the view rendering for this request. | |
In all fairness, for all but the simplest of apps, this is actually pretty tricky to do as you'll have partials, and helpers to contend with too. | |
But I've found it fairly helpful in a simple Sinatra app at work. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment