Re: [Rails] Re: to get only the updated fields

2010-03-03 Thread Andy Jeffries
> > > While technically you're right > > Way to get me onside ;-) > I'm a part-time developer and part-time sleazy politician ;-) "I completely agree with you 100%, however..." (notice no "but"). j/k > Let's split the difference... > Completely agree with the solution (and it's what I had in

Re: [Rails] Re: to get only the updated fields

2010-03-03 Thread Michael Pavling
On 3 March 2010 14:04, Andy Jeffries wrote: > While technically you're right Way to get me onside ;-) > we don't know the full facts in what he's trying to do. Agreed - the "oh, but I didn't tell you about this condition" syndrome. > :-) Let's split the difference... create a method on the us

Re: [Rails] Re: to get only the updated fields

2010-03-03 Thread Andy Jeffries
> > On 3 March 2010 13:16, Andy Jeffries wrote: > > if @user.changed? > > @user.save > > send_mail > > end > > ... and repeat that in every method that makes any updates to your user... > > Whatever works for you, though... it's your code after all. > > Be DRY > :-/ > While technically you're

Re: [Rails] Re: to get only the updated fields

2010-03-03 Thread Michael Pavling
On 3 March 2010 13:16, Andy Jeffries wrote: > if @user.changed? > �...@user.save >   send_mail > end ... and repeat that in every method that makes any updates to your user... Whatever works for you, though... it's your code after all. Be DRY :-/ -- You received this message because you are

Re: [Rails] Re: to get only the updated fields

2010-03-03 Thread Andy Jeffries
> > If you look at the source code for update_attributes, you'll see it > does a "save" in the method, so once it's finished, the are no changed > fields (because the record has already been updated). > > You need a callback filter to run in your User model; and > "before_save" seems sensible to me

Re: [Rails] Re: to get only the updated fields

2010-03-03 Thread Michael Pavling
On 3 March 2010 11:51, Tom Mac wrote: > Hi Conrad > >    Thanks for your reply. But this is not working for > update_attributes. What I tried is in update action > > @user = User.find(params[:id]) > if @user.update_attributes(params[:user]) >   send_mail if @user.changed?  #But this is always retu

[Rails] Re: to get only the updated fields

2010-03-03 Thread Tom Mac
Hi Conrad Thanks for your reply. But this is not working for update_attributes. What I tried is in update action @user = User.find(params[:id]) if @user.update_attributes(params[:user]) send_mail if @user.changed? #But this is always returns false Not working - else end