Using ERB in rails

I’m trying to do this:

erb = ERB.new(template)
result = erb.result(binding)

When I run this I get “Can only render or redirect once per action”
and I’m not sure why. I have been digging through the rails source but
there is definitely something that I am not understanding.

Any ideas?

Thanks,
Carl.

On 8/23/06, Carl W. [email protected] wrote:

Any ideas?

ERB doesn’t set either of the ‘performed’ instance variables; without
seeing
the
context, it is hard to tell what the problem might be.

But, having been burned by this myself, make sure that you are exiting
the
action after you call render - doing this

if something
render thing1
end
render thing2

where ‘thing2’ is intended as a default action, will get you the
DoubleRenderError
you’re describing. Adding a return statement after the first render will
fix
it.
The default message for DoubleRenderError is much more informative than
the
replacement supplied by the render function - check it out for more
detail.

Hope this helps,

Matt J.
[email protected]
President/Technical Director, Acme Art Company (acmeartco.org)

Guys,

I’m sorry that I posted that question. It was quite dumb. I had a
render :partial in the template that I was running through ERB. Sorry
to bother everyone.

Thanks,
Carl.

On 8/23/06, Matt J. [email protected] wrote:

When I run this I get “Can only render or redirect once per action”
But, having been burned by this myself, make sure that you are exiting the
it.
The default message for DoubleRenderError is much more informative than the
replacement supplied by the render function - check it out for more detail.

Hope this helps,

Matt J.
[email protected]
President/Technical Director, Acme Art Company (acmeartco.org)


Carl W.
0412218979
[email protected]