Hi I need to turn the html of a partial into a json object (NOT TO BE RENDERED), but to be stored in a seperate format.
Something like this:
@json = (:partial => "/answers/likers" ,:type => :html)
Although the above obviously does not work, but hope you get the point, thanks!
Try
render_to_string. It takes the same arguments asrender, and just returns a string instead of outputting the data.It looks like it’s being deprecated but I can’t find any new method that provides that same functionality for Rails 3. I tested it on a local Rails 3 setup, though, and it works for me. If anyone knows the “new” way to do this in Rails 3 please let me know, I’m interested now 🙂