开发者

Rails 2.3.x: is there render_to_string replacement?

render_to_string is deprecated but there is no replacement mentioned in the API docs. How can you render a partial to a string in a controller without using this function? I need this to do things like this:

render :update do |page|
    ...
    page.call "Lightbo开发者_Go百科x.create", render_to_string(:partial => "...", ...)
end

Or:

render :json => {
    ...,
    :message => render_to_string(:partial => "...", ...)
}


render :partial => "..." should return the rendered partial (unlike render "a_view").


render_to_string method has been moved to the ActionController::Rendering module.

Here is the render_to_string source code

Try to call render_to_string on ActionController::Base like so:

ActionController::Base.new.render_to_string ...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜