Javascript 为什么不是';这个方法不能呈现我的.js.erb文件吗?

Javascript 为什么不是';这个方法不能呈现我的.js.erb文件吗?,javascript,jquery,ruby-on-rails,ruby,ruby-on-rails-3,Javascript,Jquery,Ruby On Rails,Ruby,Ruby On Rails 3,我的视频控制器中有此方法: def notification_go current_user.render_read respond_to do |format| format.html format.js { render 'notification_go.js.erb' } end end 它不会在我的视频查看目录中呈现我的通知_go.js.erb文件。为什么会这样?如何渲染它 (我的通知\u go方法是通过AJAX请求调用的。不确定这是否有任何区别。)尝试传递

我的视频控制器中有此方法:

def notification_go
  current_user.render_read
  respond_to do |format|
    format.html
    format.js { render 'notification_go.js.erb' }
  end
end
它不会在我的
视频
查看目录中呈现我的
通知_go.js.erb
文件。为什么会这样?如何渲染它

(我的
通知\u go
方法是通过AJAX请求调用的。不确定这是否有任何区别。)

尝试传递

:format => :js 

到AJAX请求中的路径。

默认情况下,不需要指定渲染“notification_go.js.erb”,即带有控制器操作notification_go的notification_go.js.erb模板的文件名

def notification_go
  current_user.render_read
  respond_to do |format|
    format.html
    format.js
  end
end

您是否尝试过呈现“通知”?