2011-05-09 124 views
1

我有我的視頻控制器的這種方法:爲什麼不是這種方法呈現我的.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請求調用。不知道這有什麼差別。)

+0

名你有沒有嘗試'渲染「notification_go 「'? – 2011-05-09 07:25:11

回答

1

嘗試通過

:format => :js 

到路徑在您的AJAX請求。

2

你不需要指定默認渲染「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