为什么这个方法不能渲染我的.js.erb文件?

我的video控制器中有这种方法:

def notification_go current_user.render_read respond_to do |format| format.html format.js { render 'notification_go.js.erb' } end end 

它没有在我的videos视图目录中呈现我的notification_go.js.erb文件。 为什么是这样? 我该如何呈现它?

(我的notification_go方法是通过AJAX请求调用的。不确定这是否有所不同。)

尝试传球

 :format => :js 

到您的AJAX请求中的路径。

您不需要指定渲染’notification_go.js.erb’默认情况下已经映射,带有控制器操作notication_go的notification_go.js.erb模板的文件名

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