Javascript 如何编写jquery js.erb,使链接的html和ruby输出都指向:remote=>;在rails 3中?

Javascript 如何编写jquery js.erb,使链接的html和ruby输出都指向:remote=>;在rails 3中?,javascript,jquery,ruby-on-rails,Javascript,Jquery,Ruby On Rails,我的js.erb文件中有以下内容,但它不执行ruby代码: 4 //Update the number of followers 5 $('.follow-count').html("#{@followers_count} following") 混合使用ruby(以及从控制器访问内容)和常规文本的正确方法是什么?js.erb文件的工作方式与您的html.erb文件一样。您需要改用标记: $('.follow-count').html("<%= @followers_count %

我的js.erb文件中有以下内容,但它不执行ruby代码:

4 //Update the number of followers
  5 $('.follow-count').html("#{@followers_count} following")

混合使用ruby(以及从控制器访问内容)和常规文本的正确方法是什么?

js.erb
文件的工作方式与您的
html.erb
文件一样。您需要改用
标记:

 $('.follow-count').html("<%= @followers_count %> following")
$('.follow count').html(“following”)

$('.follow count').html(“following”)@Angela:Syed和Dylan的答案足以回答您的问题……:)