所有我是新的轨道。 我想销毁在分组表中有group_id的用户。为什么它发生错误,找不到用户发生,当我从组表
我的源代码在这里。
GroupsController
def leave
@user = current_user
@group = Group.find(params[:id])
@user.groupings.find_by_group_id(@group).destroy
redirect_to :back , notice: "Destroy!"
end
lists.html.haml
%td= link_to("Destroy",leave_group_path(:id => group),:confirm => "Are you sure",:method => :delete)
当我点击 “消灭” 按钮,然后就发生错误Couldn't find User with id=1
我要摧毁只有分组表,但为什么找不到current_user.I不删除current_user。
错误日志是
app/controllers/application_controller.rb:6:in `current_user'
而且CURRENT_USER提供OmniAuth插件的是helper_method。
CURRENT_USER实现以下这个..
class ApplicationController < ActionController::Base
protect_from_forgery
private
def current_user
@current_user ||= User.find(session[:user_id]) if session[:user_id]
end
helper_method :current_user
end
请一些帮助。
在此先感谢。
它是否肯定会触发该控制器操作?回溯显示错误发生在哪条线上?组播控制器上是否有过滤器? – 2011-12-25 18:09:33
什么是current_user方法和/或您使用的是什么自动系统? – andrewpthorp 2011-12-25 19:30:17
谢谢,我已经更新了我的问题内容以添加“错误日志”和current_user方法。请看这个。 – nobinobiru 2011-12-26 05:09:16