Render & Action View Outside Rails


If you need to call link_to, or even parse a partial outside Rails, you can just create a new instance of ActionView::Base, as follows:

action_view = ActionView::Base.new(
Rails::Configuration.new.view_path, {},
LogiController.new)

Where LogiController is the controller to which the partial belongs (inside view/logi).

And then you can render the partial with:

action_view.render(:partial => 'logi_link',
:locals => {:first_halve_text => text1, ...}

This also works outside Rails (I'm using it for adding a rule to RedCloth that renders a partial for Manta).
Part of the LogiLogi Network: The LogiLogi Foundation - LogiLogi.org - OgOg.org
This is an old version for archival purposes, see www.LogiLogi.org for the current version.
< Edit this document | View history | Printer friendly (inc. links) >
Visited 1221 times
Document last modified Wed, 03 Jan 2007 15:49:43
All content is available under the GNU Free Documentation License. The LogiLogi-system is under the GPL
SourceForge.net Logo Zylon Internet Services-Groningen Logo
Visitor statistics