为什么不是这种方法呈现我的.js.erb文件?
问题描述:
我有我的视频控制器的这种方法:为什么不是这种方法呈现我的.js.erb文件?
def notification_go
current_user.render_read
respond_to do |format|
format.html
format.js { render 'notification_go.js.erb' }
end
end
它不是渲染我notification_go.js.erb
文件在我videos
视图目录。为什么是这样?我如何渲染它?
(我notification_go
方法是通过Ajax请求调用。不知道这有什么差别。)
答
尝试通过
:format => :js
到路径在您的AJAX请求。
答
你不需要指定默认渲染“notification_go.js.erb”它已经被映射,与控制器动作notification_go.js.erb模板notication_go
def notification_go
current_user.render_read
respond_to do |format|
format.html
format.js
end
end
名你有没有尝试'渲染“notification_go “'? – 2011-05-09 07:25:11