i''m not sure if this is the right place for this but it its an activerecord issue so hopefully it is. anyway when ever i try and save a model it come back as true but when i find the object again it hasn''t changed. For example: p = Post.find 1 p.title.capitalize! p.save # Returns true but doesn''t actually save the logger outputs the following when i save it D, [2011-05-17T18:33:55.786908 #5595] DEBUG -- : SQL (0.2ms) BEGIN D, [2011-05-17T18:33:55.787576 #5595] DEBUG -- : SQL (0.1ms) COMMIT => true Any reason for this? Thanks, James. -- Posted via http://www.ruby-forum.com/. -- 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.
which rails? try (in console) p = Post.find 1 p.title.capitalize! p.title p.save p.errors.inspect tom On May 17, 2011, at 19:45 , james b. wrote:> i''m not sure if this is the right place for this but it its an > activerecord issue so hopefully it is. > > anyway when ever i try and save a model it come back as true but when i > find the object again it hasn''t changed. > > For example: > > p = Post.find 1 > p.title.capitalize! > p.save # Returns true but doesn''t actually save > > the logger outputs the following when i save it > > D, [2011-05-17T18:33:55.786908 #5595] DEBUG -- : SQL (0.2ms) BEGIN > D, [2011-05-17T18:33:55.787576 #5595] DEBUG -- : SQL (0.1ms) COMMIT > => true > > Any reason for this? > > Thanks, James. > > -- > Posted via http://www.ruby-forum.com/. > > -- > 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.-- ==============================================================================Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache www.meinlschmidt.com www.maxwellrender.cz www.lightgems.cz ============================================================================== -- 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 17 May 2011, at 18:45, "james b." <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> i''m not sure if this is the right place for this but it its an > activerecord issue so hopefully it is. > > anyway when ever i try and save a model it come back as true but when i > find the object again it hasn''t changed. > > For example: > > p = Post.find 1 > p.title.capitalize! > p.save # Returns true but doesn''t actually saveInplace modification of attributes confuses the change tracking in ar - either don''t do it (ie p.title = p.title.capitalize) or call the title_will_change! method after you do Fred> > the logger outputs the following when i save it > > D, [2011-05-17T18:33:55.786908 #5595] DEBUG -- : SQL (0.2ms) BEGIN > D, [2011-05-17T18:33:55.787576 #5595] DEBUG -- : SQL (0.1ms) COMMIT > => true > > Any reason for this? > > Thanks, James. > > -- > Posted via http://www.ruby-forum.com/. > > -- > 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. >-- 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.
Thanks very much i had been pondering on this for a while Final Solution: p.title = p.title.capitalize instead of p.title.capitalize! -- Posted via http://www.ruby-forum.com/. -- 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.
or p.update_attribute(:title, p.title.capitalize) and without p.save or if you want to capitalize in your model (when saving), you could do that with before filter before_save do |row| row.title = row.title.capitalize unless row.title.blank? end tom On May 17, 2011, at 22:17 , james b. wrote:> Thanks very much i had been pondering on this for a while > > Final Solution: > > p.title = p.title.capitalize > instead of > p.title.capitalize! > > -- > Posted via http://www.ruby-forum.com/. > > -- > 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.-- ==============================================================================Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache www.meinlschmidt.com www.maxwellrender.cz www.lightgems.cz ============================================================================== -- 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.