Using the console, I capture a db record into the variable ''record''. I then try to save it with the record.save method which returns false. There is nothing in the log files to indicate why the save failed. Can anyone please tell me what I might investigate to determine why the save fails? A transcript of my console session is shown below. Thanks for any input. ... doug>> record=Member.find(1)=> #<Member id: 1, login: "Mask", password: "Mask", flags: 0, first_name: "OK", last_name: "OK", email: "_OK", courtesy_title: "OK", created_at: nil, updated_at: nil, double_opt_in: nil, street: nil, street2: nil, suite: nil, city: nil, region: nil, postal_code: nil, country: nil, home_phone: nil, business_phone: nil, mobile_phone: nil, fax: nil, custom0: nil, custom1: nil, custom2: nil, custom3: nil, custom4: nil, custom5: "Meal_Preference", custom6: nil, custom7: nil, custom8: nil, custom9: nil>>> record.save=> false>>-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Dec 22, 2009, at 2:52 PM, doug wrote:> Using the console, I capture a db record into the variable ''record''. > I then try to save it with the record.save method which returns > false. There is nothing in the log files to indicate why the save > failed. Can anyone please tell me what I might investigate to > determine why the save fails? A transcript of my console session is > shown below. Thanks for any input. > > ... doug > >>> record=Member.find(1) > => #<Member id: 1, login: "Mask", password: "Mask", flags: 0, > first_name: "OK", last_name: "OK", email: "_OK", courtesy_title: "OK", > created_at: nil, updated_at: nil, double_opt_in: nil, street: nil, > street2: nil, suite: nil, city: nil, region: nil, postal_code: nil, > country: nil, home_phone: nil, business_phone: nil, mobile_phone: nil, > fax: nil, custom0: nil, custom1: nil, custom2: nil, custom3: nil, > custom4: nil, custom5: "Meal_Preference", custom6: nil, custom7: nil, > custom8: nil, custom9: nil> >>> record.save > => false >>>Try record.save! so it throws an error that you can look at. Or examine record.errors for validation failures. Also consider adding the following to your ~/.irbrc file. This will output all logging to the screen and you can look at the SQL query itself. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi Doug, You can check the validation errors after the save to figure out if the validations caused the failed save...>> record = Member.find(1) >> record.save >> record.errors.full_messages.inspectCheers, Jits 2009/12/22 doug <ddjolley-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> Using the console, I capture a db record into the variable ''record''. > I then try to save it with the record.save method which returns > false. There is nothing in the log files to indicate why the save > failed. Can anyone please tell me what I might investigate to > determine why the save fails? A transcript of my console session is > shown below. Thanks for any input. > > ... doug > > >> record=Member.find(1) > => #<Member id: 1, login: "Mask", password: "Mask", flags: 0, > first_name: "OK", last_name: "OK", email: "_OK", courtesy_title: "OK", > created_at: nil, updated_at: nil, double_opt_in: nil, street: nil, > street2: nil, suite: nil, city: nil, region: nil, postal_code: nil, > country: nil, home_phone: nil, business_phone: nil, mobile_phone: nil, > fax: nil, custom0: nil, custom1: nil, custom2: nil, custom3: nil, > custom4: nil, custom5: "Meal_Preference", custom6: nil, custom7: nil, > custom8: nil, custom9: nil> > >> record.save > => false > >> > > -- > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Dec 22, 11:24 pm, Jiten Bhagat <li...-DYnhOvfiKYO1Qrn1Bg8BZw@public.gmane.org> wrote:> Hi Doug, > > You can check the validation errors after the save to figure out if the > validations caused the failed save... >Also check if you have a before_save callback that might be stopping the save Fred> >> record = Member.find(1) > >> record.save > >> record.errors.full_messages.inspect > > Cheers, > Jits > > 2009/12/22 doug <ddjol...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > > > > Using the console, I capture a db record into the variable ''record''. > > I then try to save it with the record.save method which returns > > false. There is nothing in the log files to indicate why the save > > failed. Can anyone please tell me what I might investigate to > > determine why the save fails? A transcript of my console session is > > shown below. Thanks for any input. > > > ... doug > > > >> record=Member.find(1) > > => #<Member id: 1, login: "Mask", password: "Mask", flags: 0, > > first_name: "OK", last_name: "OK", email: "_OK", courtesy_title: "OK", > > created_at: nil, updated_at: nil, double_opt_in: nil, street: nil, > > street2: nil, suite: nil, city: nil, region: nil, postal_code: nil, > > country: nil, home_phone: nil, business_phone: nil, mobile_phone: nil, > > fax: nil, custom0: nil, custom1: nil, custom2: nil, custom3: nil, > > custom4: nil, custom5: "Meal_Preference", custom6: nil, custom7: nil, > > custom8: nil, custom9: nil> > > >> record.save > > => false > > > -- > > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscrib e@googlegroups.com> > > . > > For more options, visit this group at > >http://groups.google.com/group/rubyonrails-talk?hl=en.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> You can check the validation errors after the save to figure out if the > validations caused the failed save...Fred, you''re absolutely right. It was a validation issue that caused the failed save. I had already figured that out using the techniques offered by the other 2 contributors. All is well and I am a happy camper. Thanks to all for the very helpful input. ... doug -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.