0
當我通過cURL請求在Redmine上創建故障單時,出現此錯誤。我的cURL成功創建了票證,但它也返回了一個錯誤,我無法理解爲什麼會這樣。NoMethodError(未定義方法`id'爲零:NilClass)
這裏是我得到的錯誤:
Started POST "/issues.json" for 122.161.50.0 at 2016-04-16 07:18:22 +0000
Processing by IssuesController#create as JSON
Parameters: {"issue"=>{"project_id"=>10, "tracker_id"=>7, "status_id"=>1, "priority_id"=>3, "subject"=>"Issue created from CURL"}}
Current user: himanshu (id=3)
Rendered mailer/_issue.text.erb (6.8ms)
Rendered mailer/issue_add.text.erb within layouts/mailer (45.6ms)
Rendered mailer/_issue.html.erb (2.3ms)
Rendered mailer/issue_add.html.erb within layouts/mailer (6.9ms)
Completed 500 Internal Server Error in 724.8ms
NoMethodError (undefined method `id' for nil:NilClass):
lib/redmine/hook.rb:61:in `block (2 levels) in call_hook'
lib/redmine/hook.rb:61:in `each'
lib/redmine/hook.rb:61:in `block in call_hook'
lib/redmine/hook.rb:58:in `tap'
lib/redmine/hook.rb:58:in `call_hook'
lib/redmine/hook.rb:153:in `call_hook'
app/controllers/issues_controller.rb:151:in `create'
這是控制器代碼
def create
call_hook(:controller_issues_new_before_save, { :params => params, :issue => @issue })
@issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads]))
if @issue.save
call_hook(:controller_issues_new_after_save, { :params => params, :issue => @issue})
respond_to do |format|
format.html {
render_attachment_warning_if_needed(@issue)
flash[:notice] = l(:notice_issue_successful_create, :id => view_context.link_to("##{@issue.id}", issue_path(@issue), :title => @issue.subject))
if params[:continue]
attrs = {:tracker_id => @issue.tracker, :parent_issue_id => @issue.parent_issue_id}.reject {|k,v| v.nil?}
redirect_to new_project_issue_path(@issue.project, :issue => attrs)
else
redirect_to issue_path(@issue)
end
}
format.api { render :action => 'show', :status => :created, :location => issue_url(@issue) }
end
return
else
respond_to do |format|
format.html { render :action => 'new' }
format.api { render_validation_errors(@issue) }
end
end
end
這是調用一個鉤子
def call_hook(hook, context={})
[].tap do |response|
hls = hook_listeners(hook)
if hls.any?
hls.each {|listener| response << listener.send(hook, context)}
end
end
end
我看到151線'''controller_issues_new_after_save'''看起來你已經安裝的插件創建問題之後被調用,並指PARAMS。 – Noma4i