Forum: Ruby on Rails detecting changed data

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C1e5a9e9344b6d31b9df7303e6dc378a?d=identicon&s=25 Craig White (Guest)
on 2006-05-31 19:21
(Received via mailing list)
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
30ee518e6fdc5b07e060775b5a542bdb?d=identicon&s=25 Jón Borgþórsson (jongretar)
on 2006-05-31 19:31
(Received via mailing list)
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 White <craigwhite@azapple.com> wrote:
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>


--
30ee518e6fdc5b07e060775b5a542bdb?d=identicon&s=25 Jón Borgþórsson (jongretar)
on 2006-05-31 19:34
(Received via mailing list)
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 Borgthorsson <jon.borgthorsson@gmail.com> wrote:
> > they attempt to change screens without having saved their changes to the
>
> --
> --------------
> Jon Gretar Borgthorsson
> http://www.jongretar.net/
>


--
C1e5a9e9344b6d31b9df7303e6dc378a?d=identicon&s=25 Craig White (Guest)
on 2006-06-04 23:16
(Received via mailing list)
On Wed, 2006-05-31 at 17:25 +0000, Jon Gretar Borgthorsson 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<br />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
This topic is locked and can not be replied to.