Just a quick question, and is related to Ruby objects into JavaScript . I am a student under Martin, and we were wondering if there is a possibility to embed Ruby Objects into the form.js, without using form.yml.erb as a mediator with the HTML.
Hi Jeff, we want to pass a static key-value pair structure that contains mapping of GPU type and its description, e.g. (“1080ti”,“Nvidia GeForce 1080Ti”) to show in the pull down for a choice of GPU. We had it originally in the form.js as a Javascript object, but, I’d prefer it to be editable at a single location, so our thought is to have it in a text file, read in the ood.rb, and then through the form.yml.erb data inject into the form.js.
I don’t think so. Or at least I don’t think there’s a way to do what you want - inject into javascript. You can have javascript read data of the HTML page, but I don’t think there’s a clean way in 3.1 to go the other way.