Detecting changed data

I am working on an application where there are many different screens to
access the data in a particular record/row. I have links to each data
entry screen at the top. Is there a way to detect whether the current
hash has been changed from the stored record so I can prompt the user if
they attempt to change screens without having saved their changes to the
data?

Craig

Create a row in your database called “updated_on” in the format
“datetime”. Rails will automatically add the date-time on update.
Then you can just compare hashed_item.updated_on to
model_item.updated_on and see if it’s the same or not.

On 5/31/06, Craig W. [email protected] wrote:

Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

Oh i forgot. Watch that you don’t write the old date into the database
since you have it in your hash.

On 5/31/06, Jon Gretar B. [email protected] wrote:

they attempt to change screens without having saved their changes to the

Jon Gretar B.
http://www.jongretar.net/

On Wed, 2006-05-31 at 17:25 +0000, Jon Gretar B. wrote:

they attempt to change screens without having saved their changes to the
data?


this doesn’t seem to work. Each edit screen has in controller…

@personnel = Personnel.find_by_id(params[:id])

and I have view code which looks like…

<%= link_to ‘Employment
Information’, :action =>
‘edit_employment’, :id => @personnel.id, :test => @personnel.updated_at
%>

and this ALWAYS sends the value stored in the record even if I change a
value on that screen before I click the ‘link_to’, thus the ‘updated_at’
value in the hash doesn’t change if I change a value elsewhere.

Any hints?

Craig