Hi, I want to update an existing row in table "items" where items.id == 10 I tried this: item = Item.new item.f1 = ... item.f2 = ... ... item.id = 10 item.save I got an error Duplicate entry ... for key 10 : INSERT INTO items ... How do I make item.save to use UPDATE instead of INSERT? -- Posted via http://www.ruby-forum.com/.
On 12/22/05, r00by n00by <uakpxmgxswozo-hRtevi7K+EU+Va1GwOuvDg@public.gmane.org> wrote:> Hi, > > I want to update an existing row in table "items" where items.id == 10 > I tried this: > > item = Item.new > item.f1 = ... > item.f2 = ... > ... > item.id = 10 > item.save > > I got an error > Duplicate entry ... for key 10 : INSERT INTO items ... > > How do I make item.save to use UPDATE instead of INSERT?item = Item.find 10 item.f1 = ... item.f2 = ... item.save Joe
r00by n00by wrote:> Hi, > > I want to update an existing row in table "items" where items.id == 10 > I tried this: > > item = Item.new > item.f1 = ... > item.f2 = ... > ... > item.id = 10 > item.save > > I got an error > Duplicate entry ... for key 10 : INSERT INTO items ... > > How do I make item.save to use UPDATE instead of INSERT?item = Item.find(10) item.f1 = ... item.f2 = ... ... item.save -- Posted via http://www.ruby-forum.com/.
I am looking for a program I can put into a web page for recording and playback of audio files. It is assumed that the client machne has sound card, microphone, etc. It is OK to restrict to IE if necessary. Anyone tackle this one? Thanks in advance, John B
the easiest is to use the flashplayer (wich is on 98% of all computers), whichi s abel to record and playback audio. At the backend you need a flash communication server for receiving the upstreamed recordings. To create and control dynmaically flash-movies from within a rails app, I would take a look at http://aflax.org , which is kind of a Javascript-Flash bridge. regards On 12/22/05, speechexpert <speechexpert-rphTv4pjVZMJGwgDXS7ZQA@public.gmane.org> wrote:> > I am looking for a program I can put into a web page for recording and > playback of audio files. > It is assumed that the client machne has sound card, microphone, etc. > It is OK to restrict to IE if necessary. > Anyone tackle this one? > Thanks in advance, > John B > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Roberto Saccon - http://rsaccon.com _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Marc Love wrote:> r00by n00by wrote: >> Hi, >> >> I want to update an existing row in table "items" where items.id == 10 >> I tried this: >> >> item = Item.new >> item.f1 = ... >> item.f2 = ... >> ... >> item.id = 10 >> item.save >> >> I got an error >> Duplicate entry ... for key 10 : INSERT INTO items ... >> >> How do I make item.save to use UPDATE instead of INSERT? > > item = Item.find(10) > item.f1 = ... > item.f2 = ... > ... > item.saveSometimes the value of item is already given (not from the database), so I need to do something like this: item10 = Item.find(10) item10 = item.clone item10.save but this dosn''t work. What''s the right way to do it? -- Posted via http://www.ruby-forum.com/.
On 12/24/05, r00by n00by <0539y2fupguaui80-1YkopTs1fDFBDgjK7y7TUQ@public.gmane.org> wrote:> Marc Love wrote: > > r00by n00by wrote: > >> Hi, > >> > >> I want to update an existing row in table "items" where items.id == 10 > >> I tried this: > >> > >> item = Item.new > >> item.f1 = ... > >> item.f2 = ... > >> ... > >> item.id = 10 > >> item.save > >> > >> I got an error > >> Duplicate entry ... for key 10 : INSERT INTO items ... > >> > >> How do I make item.save to use UPDATE instead of INSERT? > > > > item = Item.find(10) > > item.f1 = ... > > item.f2 = ... > > ... > > item.save > > > > Sometimes the value of item is already given (not from the database), so > I need to do something like this: > > item10 = Item.find(10) > item10 = item.clone > item10.save > > but this dosn''t work. What''s the right way to do it?Maybe use dclone?>> original = Role.find :first=> #<Role:0x2aaaac65d830 @attributes={"name"=>"Community / Local Village Director", "training_link"=>"http://www.cnn.com", "id"=>"1"}>>> new_one = original.dclone=> #<Role:0x2aaaac65a2c0 @new_record=true, @attributes={"name"=>"Community / Local Village Director", "training_link"=>"http://www.cnn.com"}>>> new_one.save=> true>> new_one=> #<Role:0x2aaaac65a2c0 @errors=#<ActiveRecord::Errors:0x2aaaac653178 @errors={}, @base=#<Role:0x2aaaac65a2c0 ...>>, @new_record=false, @new_record_before_save=false, @attributes={"name"=>"Community / Local Village Director", "training_link"=>"http://www.cnn.com", "id"=>5}>