How to embed Ruby in JavaScript (Rails + .html.erb file)

后端 未结 4 1033

I have a .html.erb file, with some javascript in it. I would like to do something like this:

var stuff = \'
<%= @ruby_var.title %>
\'
4条回答
  •  难免孤独
    2021-02-05 07:39

    Ruby can't be run on the client, at least not with specialized browser plugins. Instead, look at using AJAX and RJS to query your Ruby web application from Javascript and insert any text it returns into your page.

    Without more information, I don't think you're going to get any better answers. I might be totally off too, because I'm only guessing at what you really want to do.

提交回复
热议问题