Maybe I am totally waisted after a long nights work with my admin interface filters but how the heck can I duplicate records? Scenario: My client will enter hundreds maybe thousands of products into their new nice e-commerce system backoffice forms. They call me and say, Hey! Can we press a "DUPLICATE" button would safe us hours and hours of time when adding products. Solution? I can''t find any posts about this issues on the lists archives or anywhere else for that matter. I just want to have in my scaffolds next to show, edit, destroy a new link with the label "Duplicate and Edit" and if you press this link it should take the data on the selected product, copy it to a new product and go to the edit screen of that new product. Any ideas on how to accomplish this? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Andreas Kviby wrote:> Maybe I am totally waisted after a long nights work with my admin > interface filters but how the heck can I duplicate records? > > Scenario: > My client will enter hundreds maybe thousands of products into their > new nice e-commerce system backoffice forms. They call me and say, > Hey! Can we press a "DUPLICATE" button would safe us hours and hours > of time when adding products. > > Solution? > I can''t find any posts about this issues on the lists archives or > anywhere else for that matter. I just want to have in my scaffolds > next to show, edit, destroy a new link with the label "Duplicate and > Edit" and if you press this link it should take the data on the > selected product, copy it to a new product and go to the edit screen > of that new product. > > Any ideas on how to accomplish this?How about object.clone? -- Cheers, - Jacob Atzen --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
#controller def duplicate_and_edit @product = Product.find(params[:id] @product.id = nil end if your form in new.rhtml is populated with form_for @product ...... , you could just render this action and rails will fill in the values into the form and thus reuse this view instead a creating a duplicate form for this action. On 20 Jul., 12:19, Andreas Kviby <akv...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Maybe I am totally waisted after a long nights work with my admin > interface filters but how the heck can I duplicate records? > > Scenario: > My client will enter hundreds maybe thousands of products into their > new nice e-commerce system backoffice forms. They call me and say, > Hey! Can we press a "DUPLICATE" button would safe us hours and hours > of time when adding products. > > Solution? > I can''t find any posts about this issues on the lists archives or > anywhere else for that matter. I just want to have in my scaffolds > next to show, edit, destroy a new link with the label "Duplicate and > Edit" and if you press this link it should take the data on the > selected product, copy it to a new product and go to the edit screen > of that new product. > > Any ideas on how to accomplish this?--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Thanks a lot, it worked like a charm. Thanks to you guys my client will be very happy today. /Andreas Read my blog at www.swerails.se On 20 Juli, 12:42, Thorsten <duple...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> #controller > def duplicate_and_edit > @product = Product.find(params[:id] > @product.id = nil > end > > if your form in new.rhtml is populated with form_for @product ...... , > you could just render this action and rails will fill in the values > into the form and thus reuse this view instead a creating a duplicate > form for this action. > > On 20 Jul., 12:19, Andreas Kviby <akv...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Maybe I am totally waisted after a long nights work with my admin > > interface filters but how the heck can I duplicate records? > > > Scenario: > > My client will enter hundreds maybe thousands of products into their > > new nice e-commerce system backoffice forms. They call me and say, > > Hey! Can we press a "DUPLICATE" button would safe us hours and hours > > of time when adding products. > > > Solution? > > I can''t find any posts about this issues on the lists archives or > > anywhere else for that matter. I just want to have in my scaffolds > > next to show, edit, destroy a new link with the label "Duplicate and > > Edit" and if you press this link it should take the data on the > > selected product, copy it to a new product and go to the edit screen > > of that new product. > > > Any ideas on how to accomplish this?--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---