【发布时间】:2011-12-18 22:51:26
【问题描述】:
我想要的只是复制现有记录。它应该使用填充的数据呈现新表单并让我“创建”这条新记录。
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
【问题讨论】:
标签: ruby-on-rails-3 clone duplicate-data