【发布时间】:2011-03-24 06:22:07
【问题描述】:
当我在我的用户控制器中点击这个销毁方法时,我遇到了以下错误。
AbstractController::DoubleRenderError(在此操作中多次调用渲染和/或重定向。 请注意,您只能 调用渲染或重定向,每个操作最多一次。另请注意 既不重定向也不渲染终止动作的执行,所以如果 你想在重定向后退出一个动作,你需要做一些事情 比如“redirect_to(...) and return”。):
这很奇怪,因为老实说我只回复一次电话。
这是我的行动:
def destroy
user = User.find(params[:id])
if user.has_role_for? current_client
# then we remove the role
user.has_no_roles_for! current_client
# was that the users only role?
if user.roles.count == 0
user.destroy
end
respond_with head :ok
else
respond_with({:error=>'unauthorised'}, :status => :forbidden)
end
end
有什么想法吗?
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 internal-server-error respond-to