Storeorder 특성을 편집하려고 할 때 Storeorder에 중첩 된 특성이있는 작업 테이블에서 인라인 편집을 수행하려면 Best In Place Gem을 사용하고 있습니다 this post에 제공된 지침을 사용하면 204 번 내용 오류가 발생합니다. 'Storeorder Load'가 발생하기 전에 첫 번째 거래 시작과 관련이 있는지 궁금합니다. 중첩되지 않은 모든 BIP 업데이트에서 첫 번째 '트랜잭션 시작'호출 내에서 UPDATE를 수행하지만 여기에서는 여전히 Storeorder를로드합니다. 매개 변수는 내가 말할 수있는 한 100 % 정확합니다. >best_in_place 중첩 된 특성 인라인 편집 "204 No Content"오류가 발생했습니다
class TasksController < ApplicationController
before_action :set_task, only: [:show, :edit, :update, :destroy]
def update
@task = Task.find(params[:id])
respond_to do |format|
if @task.update(task_params)
format.html { redirect_to @task, notice: 'Task was successfully updated.' }
format.json { respond_with_bip(@task) }
else
format.html { render :edit }
format.json { respond_with_bip(@task) }
end
end
end
private
def set_task
@task = Task.find(params[:id])
end
def task_params
params.require(:task).permit!
end
end
task.rb - ->
class Task < ApplicationRecord
has_one :storeorder, :dependent => :destroy
accepts_nested_attributes_for :storeorder, :reject_if => lambda { |a| a[:store_id].blank? }, :allow_destroy => true
end
storeorder.rb ->
class Storeorder < ApplicationRecord
belongs_to :task
end
대시 보드, 코드
Started PUT "/tasks/3" for 104.200.151.54 at 2017-02-05 18:08:24 +0000
Processing by TasksController#update as JSON
Parameters: {"task"=>{"storeorder_attributes"=>{"id"=>"3", "activity"=>"Shipped"}}, "authenticity_token"=>"D2c3ddoIC220rkPE5i7U+EGiwSrdCq7s8vdFY8VEQTaTMqetuBo8SJX9+Wabl+Bh6A6d49Pt/Omp4E/nq/udQA==", "id"=>"3"}
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT ? [["id", 1], ["LIMIT", 1]]
Task Load (0.2ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."id" = ? LIMIT ? [["id", 3], ["LIMIT", 1]]
CACHE (0.0ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."id" = ? LIMIT ? [["id", 3], ["LIMIT", 1]]
(0.1ms) begin transaction
Storeorder Load (0.2ms) SELECT "storeorders".* FROM "storeorders" WHERE "storeorders"."task_id" = ? LIMIT ? [["task_id", 3], ["LIMIT", 1]]
(0.1ms) commit transaction
(0.1ms) begin transaction
(0.1ms) commit transaction
Completed 204 No Content in 10ms (ActiveRecord: 1.0ms)
tasks_controller.rb를 참조하십시오 .html.erb ->
<td><%= best_in_place task.storeorder, :activity,
url: task_path(task.id),
param: "task[storeorder_attributes][id]=#{task.storeorder.id}&task[storeorder_attributes]",
as: :select,
collection: [["Pending Shipment", "Pending Shipment"], ["Shipped", "Shipped"], ["Cancelled", "Cancelled"], ["Pending Further Action", "Pending Further Action"]], %>
</td>
내부 HTML 코드 ->
<span
data-bip-type="select"
data-bip-attribute="activity"
data-bip-collection="[["Pending Shipment","Pending Shipment"],["Shipped","Shipped"],["Cancelled","Cancelled"],["Pending Further Action","Pending Further Action"]]"
data-bip-inner-class="form-control"
data-bip-object="task[storeorder_attributes][id]=3&task[storeorder_attributes]"
data-bip-original-content="Pending Shipment"
data-bip-skip-blur="false"
data-bip-url="/tasks/3"
data-bip-value="Shipped"
class="best_in_place form-control"
id="best_in_place_storeorder_3_activity">
Shipped
</span>
내가 가능성이 에러의 원인이 누락 될 수있는 것을 볼 수 없습니다. 워크 플로우의 일관성을 유지하기 위해 인라인 편집을하는 것이 필수적입니다. 그렇지 않으면 BIP가 기본적으로 범위 내에서 중첩 된 속성 편집을하지 않기 때문에 대안 제안을 할 수 있습니다.
204 응답은 오류 코드가 아닙니다. 레코드가 데이터베이스에서 업데이트되고 있는지 확인해야합니다. –
그것이 무엇이든, 레코드를 올바르게 업데이트하지 않습니다. –