0
원하는 모든 것은 기존 레코드를 복제하는 것입니다. 채워진 데이터로 새로운 양식을 렌더링하고이 새로운 레코드를 '만들어야'합니다.레일즈 복제 레코드가 새로 렌더링되지 않습니다.
def clone
@agreement = Agreement.find_by_slug!(params[:id])
@agreement.clone
respond_to do |format|
format.html { render action: "new", notice: 'Agreement was successfully cloned.' }
end
end
내 모델
def clone
self.dup()
self.slug = nil
end
는이 오류 얻을 :
No route matches {:action=>"show", :controller=>"agreements", :format=>nil, :id=>#<Agreement id: 1, date: "2011-12-18",...`
경로를
resources :agreements do
member do
post 'approve'
get 'clone', :controller => 'agreements', :action => 'clone'
end
end
감사합니다. @Robin 오류가 발생했습니다. 복제 작업이 완료되었습니다. has_many 연관도 포함시키는 방법에 대한 아이디어가 있습니까? 나는 또한 이전 문제에서 나온 유산 인 나의 노선에서 털이 벗겨졌다. – Gaelle
나는 잠시 동안이 질문에 대한 좋은 답을 찾기 위해 노력해왔다. 이것은 제가 찾은 최고의 것입니다. 더하기 그것은 작동합니다! – memoht