我正在研究Ruby on Rails的实时项目。每次将新数据存储到数据库中(尽管命中Ajax URL时)都创建新管道时,我有一个管道部分,但是现在的问题是ajax url没有响应,但是数据成功存储在数据库中
Ajax网址:
url: '/new_pipelines'
type: 'Post'
dataType: 'json'
data: {pipeline:{pipelinegraphtype:pipelinegraphtype, name:tags_or_pipeline_name, published:"0", scheduler_id:"22", state:"prepared"},pipelinegraphname:pipelinegraphtype}
success: (data) ->
console.log('Request 155 success')
error: () ->
console.log('Request 155 fail')
创建方法:
def create
@pipeline = current_user.pipelines.new params[:pipeline]
if @pipeline.save
@pipeline.save
render json: @pipeline
else
render new
end
end
路线:
match '/new_pipelines' => 'new_pipelines#create'
答案 0 :(得分:0)
尝试
def create
@pipeline = current_user.pipelines.new params[:pipeline]
if @pipeline.save
respond_to do |format|
format.json {render json: @pipeline}
end
else
render new
end
end
$.ajax({
url: '/new_pipelines'
type: 'POST'
dataType: 'json'
data: {pipeline:{pipelinegraphtype:pipelinegraphtype, name:tags_or_pipeline_name, published:"0", scheduler_id:"22", state:"prepared"},pipelinegraphname:pipelinegraphtype}
success: (data) ->
console.log('Request 155 success')
error: () ->
console.log('Request 155 fail')
});