开发者

Why isn't this method rendering my .js.erb file?

开发者 https://www.devze.com 2023-03-04 18:20 出处:网络
I have this method in my videos controller: def notification_go current_user.render_read respond_to do |format|

I have this method in my videos controller:

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

It is not rendering my notification_go.js.erb file in my videos view directory. Why is this? How do I render it?

开发者_开发技巧

(My notification_go method is called via an AJAX request. Not sure if that makes any difference.)


you dont need to specify render 'notification_go.js.erb' by default its already been mapped, the filename of notification_go.js.erb template with controller action notication_go

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


Try passing

:format => :js 

to path in your AJAX request.

0

精彩评论

暂无评论...
验证码 换一张
取 消