轨道3:redirect_to时使用:远程=>真正轨道、redirect_to、GT

2023-09-11 00:39:48 作者:Coisini 「怦然心动」

我有一个删除链接,使远程调用:

I have a delete link that makes a remote call:

<%= link_to image_tag("trash.png"), [current_user, bookcase], method:  :delete, :remote => true, confirm: "You sure?", title:   bookcase.image %>

在我的控制,我结束了重定向删除功能:

In my controller, I end the delete function with a redirect:

def destroy
  @bookcase.destroy
  redirect_to current_user
end

这工作,但它是将用户重定向到用户/ show.html.erb的文件,而不是用户/ show.js.erb文件。我怎样才能将用户重定向,指定要使用的格式?

This works, except it's redirecting the user to the 'user/show.html.erb' file instead of the 'user/show.js.erb' file. How can I redirect the user, specifying which format to use?

推荐答案

我是pretty的肯定,你可以在redirect_to时这样

I'm pretty sure you can specify the format in the redirect_to like this

redirect_to时CURRENT_USER,格式为:JS

 
精彩推荐
图片推荐