I am looping instance variable "@packages" set in controller and am trying to assign single object into one of the html element by using "data-". For changing ruby object into json i am using ".to_json" as follows: I am looping instance variable "@packages" set