저는 레일스 놈입니다. 문제 해결에 어려움을 겪고 있습니다.best_in_place와 중첩 된 속성이있는 레일 3 문제
내가 (기본 보석 외에) 다음과 같은 보석과 레일 3.2.13을 사용하고 있습니다 :
gem 'devise'
gem 'cancan'
gem 'cocoon'
gem 'best_in_place'
나는이 경우, 중첩 된 모델 작업을 고치를 사용하고
내가 가지고 (고안) 사용자가 has_many
이고 프로젝트가 각각 has_many
입니다.
난에 표시 (클릭에 편집 될) 수있는 모든 정보를 얻을 수 있어요 :
<% @project.tasks.each do |task| %>
<%= best_in_place task, :description, :path => tasks_path, :type => :input %>
<% end %>
내 문제는 내 중첩 된 작업에 대한 업데이트를 저장 best_in_place되지 수 이다 속성.
프로젝트 모델 :
class Project < ActiveRecord::Base
belongs_to :user
has_many :tasks
attr_accessible :description, :name, :tasks_attributes, :user_id, :tasks
accepts_nested_attributes_for :tasks, :reject_if => :all_blank, :allow_destroy => true
end
작업 모델 :
class Task < ActiveRecord::Base
belongs_to :project
attr_accessible :description, :done, :hours
end
프로젝트 컨트롤러 :
class ProjectsController < ApplicationController
before_filter :authenticate_user!
def show
@project = Project.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render :json => @project }
end
end
def update
@project = Project.find(params[:id])
respond_to do |format|
if @project.update_attributes(params[:project])
format.html { redirect_to @project, :notice => 'Project was successfully updated.' }
#format.json { head :no_content }
format.json { respond_with_bip(@project) }
else
format.html { render :action => "edit" }
#format.json { render :json => @project.errors, :status => :unprocessable_entity }
format.json { respond_with_bip(@project) }
end
end
end
end
개 프로젝트는 -> show.html.erb : https://github.com/bernat/best_in_place/issues/51 이에 따라
은<% @project.tasks.each do |task| %>
<li class="module-list-item ui-state-default clear">
<section class="task-name left">
<%= best_in_place task, :description, :path => tasks_path, :type => :input %>
</section>
</li>
<% end %>
업데이트 할 때 params []에있는 내용은 무엇입니까? 어쩌면 best_in_place가 잘못된 매개 변수를 보내고 있습니다. params [: project]와 update_attributes (params [: project])에 아무 것도 없을 것입니다. – stef