加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 过滤器链停止为[:login_required] rendered_o

发布时间:2020-12-17 01:21:07 所属栏目:百科 来源:网络整理
导读:希望我可以很好地解释这一点,但是如果需要更多的信息,请让我知道! 我正在建立一个用户可以创建“事件”的表单.这个事件有以下关系: belongs_to:customer(customer has_many事件) belongs_to:user(user has_many事件) has_one:incident_status(incident_
希望我可以很好地解释这一点,但是如果需要更多的信息,请让我知道!

我正在建立一个用户可以创建“事件”的表单.这个事件有以下关系:

> belongs_to:customer(customer has_many事件)
> belongs_to:user(user has_many事件)
> has_one:incident_status(incident_status属于事件)

该表单允许用户将事件分配给用户(选择表单),然后选择事件状态.事件嵌套在客户端.

但是,我在服务器日志中得到以下内容:

Processing IncidentsController#create (for 127.0.0.1 at 2010-04-26 10:41:33) [POST]
Parameters: {"commit"=>"Create","action"=>"create","authenticity_token"=>"YhW++vd/dnLoNV/DSl1DULcaWq/RwP7jvLOVx9jQblA=","customer_id"=>"4","controller"=>"incidents","incident"=>{"title"=>"Some Bad Incident","incident_status_id"=>"1","user_id"=>"2","other_name"=>"SS01-042310-001"}}

User Load (0.3ms)   SELECT * FROM "users" WHERE ("users"."id" = 2) LIMIT 1
Redirected to http://localhost:3000/session/new
Filter chain halted as [:login_required] rendered_or_redirected.
Completed in 55ms (DB: 0) | 302 Found [http://localhost/customers/4/incidents]

它看起来像是试图收集有关用户的信息,即使它已经具有id(这是创建事件所需的),用户可能没有权限执行这样的select语句?我很困惑

这是事件控制器中的相关(我认为)信息.

before_filter :login_required,:get_customer

def new
  @incident = @customer.incidents.build
  @users = @customer.users
  @statuses = IncidentStatus.find(:all)

  respond_to do |format|
    format.html # new.html.erb
    format.xml  { render :xml => @incident }
  end
end

def create
  @incident = @customer.incidents.build(params[:incident])

  respond_to do |format|
    if @incident.save
      flash[:notice] = 'Incident was successfully created.'
      format.html { redirect_to(@incident) }
      format.xml  { render :xml => @incident,:status => :created,:location => @incident }
    else
      format.html { render :action => "new" }
      format.xml  { render :xml => @incident.errors,:status => :unprocessable_entity }
    end
  end
end

就像一个FYI,我正在使用restful_authentication插件.

因此,总而言之,当我提交事件创建表单时,它不会因为停止而保存事件.我还是很新的轨道,所以我在诊断这样的问题的技能还是很糟糕的.我要去圈子:)

提前感谢任何帮助.如果需要更多信息,请让我知道,我会在其中进行编辑!

解决方法

只需在控制器中使用以下命令.
before_filter :login_required,:except=>[:new,:create]

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读