Created
June 28, 2011 08:26
-
-
Save kmamykin/1050726 to your computer and use it in GitHub Desktop.
How to render Rails 3 view in a rake task
This file contains 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
task :renderview => :environment do | |
app = YourApp::Application | |
app.routes.default_url_options = { :host => 'xxx.com' } | |
controller = YourController.new | |
view = ActionView::Base.new(app.config.paths.app.views.first, {}, controller) | |
view.class_eval do | |
include ApplicationHelper | |
include app.routes.url_helpers | |
end | |
puts view.render(:template => 'your/action') | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment