Rails Render Partial With Json Object
In my rails app I have a javascript callback after the a post is created that polls a processing endpoint to check if an image has finished processing and then updates the view lik
Solution 1:
I was able to get it work by rendering the partial as a string of HTML inside of the json object, similar to what's being done in this question: rails 3 - How to render a PARTIAL as a Json response
I changed the if statement in post_controller.rb to:
if !@post.image_processing?
data[:partial] = render_to_string(@post)
end
and then in create.js.erb changed the callback to:
$("#js-capture-container").html(data.partial);
very nice, very clean.
Post a Comment for "Rails Render Partial With Json Object"