
Optimistic locks don't work
Reported by Joseph Ridgway | September 25th, 2009 @ 06:45 PM
Note I'm using PostgreSQL. Line 155 in engines/adva_cms/app/controllers/admin/articles_controller.rb evaluates to true when it shouldn't:
if @article.updated_at && (Time.zone.parse(updated_at) != @article.updated_at)
It looks like @article.updated_at includes microseconds. My solution is to convert both to strings before evaluating:
if @article.updated_at && (Time.zone.parse(updated_at).to_s != @article.updated_at.to_s)
This works but might not be the best solution.
Comments and changes to this ticket
-
Marko Seppä September 29th, 2009 @ 11:08 AM
- State changed from new to resolved
Hi Joseph,
I ended up fixing this just by parsing the @article.updated_at with Time.zone.parse (it then drops the usecs away when updated_at is first made a string so we can parse it)
http://github.com/svenfuchs/adva_cms/commit/032aec10e4044c76f26c71f...
Now we are still working with time objects and not with strings and it felt little more right for me.
-- Marko
-
ava james March 24th, 2023 @ 11:57 AM
Nice post thanks for sharing check this. lightinthebox discount code
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<p>Cutting edge cms, blog, wiki, forum ... plattform.</p>
<p>Find the code on <a href="http://github.com/svenfuchs/adva_cms/tree/master">GitHub: adva cms</a></p>
<p>Part of the business application framework <a href="http://www.advabest.org/">adva best</a>.</p>