rails 3 json encode for consumption in javascript -


I know that to_json has been disliked and as_json is giving me problems.

This line works fine, but To_json is deprecated: New IS.Presentation (& lt;% = raw (@ course_step.step.step_presentation.step_presentation_files Map {| item} {'url' = & gt; item.slide

post-text "itemprop =" text ">

ActiveSupport supports JSON You can see here Are:

  Ruby-1.9.2-P 136: 003> J = ActiveSupport :: JSON => ActiveSupport :: JSON ruby-1.9.2-p136: 004 & gt; ; J. Encode ({: Team = & gt; "Celtics",: players => "20"}) 
"{\" Team \ ": \" Celtics \ ", \" Player \ ": \ "20 \"} "Ruby-1.9.2-P 136: 005> J.decode (" {\ "team \": \ "Celtics \", \ " "Team" => "Celtics", "Player" =>, "20"}

This will be:

  New IS.Presentation (& lt;% = ActiveSupport :: JSON.encode (raw (@ course_step.step.step_production.step_represent__files.map {| item | {'url '= & Gt; Items. slide.url,' title '= & gt; Item.title}})))%);)    

Comments