轨道3:redirect_to时使用:远程=>真正 [英] Rails 3: redirect_to with :remote => true

查看:129
本文介绍了轨道3:redirect_to时使用:远程=>真正的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

这篇关于轨道3:redirect_to时使用:远程=&GT;真正的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆