How can I compare an entry? @edit = Data.find(4) After this, user update some data en press submit. How can compare, is there any changes in new @edit and what is in database? Have user chnged any data or pressed just submit without changes? -- 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-/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 -~----------~----~----~----~------~----~------~--~---
rubyguy-DaQTI0RpDDMAvxtiuMwx3w@public.gmane.org
2009-Mar-12 18:40 UTC
Re: Compare changes.
On 12 Mar., 18:13, Fresh Mix <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> How can compare, is there any changes in new @edit and what is in > database? > Have user chnged any data or pressed just submit without changes?Try this in the #update action. It''s untested: @edited_data = Data.new(params[:data]) @original_data = Data.find(params[:id]) if @edited_data == @original_data # The data is NOT changed... else # The data IS changed... end I don''t know if the == operator works in this case, but try it out and come back if you get problems. :) -- Cheers, David Knorr http://twitter.com/rubyguy --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---