开发者

Rails 2.3.x: is there render_to_string replacement?

开发者 https://www.devze.com 2023-03-04 02:32 出处:网络
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 lik

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

精彩评论

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