Adding an "Edited at:"

I’m looking to add an edited_at field on comments etc in a Rails 5 app
(only shown if it has been edited).
I know I can compare created_at and updated_at to check if the comment
has been edited but it seems like a hit on the db if there are a lot of
comments.

Should I add an edited at boolean to the table and update it after edit?
Or am I as well to just compare created_at and updated_at?

Or is there some mechanism I can use that makes more sense than either
of these?

Johnny

On 3 May 2016 at 16:26, Johnny S. [email protected] wrote:

I’m looking to add an edited_at field on comments etc in a Rails 5 app
(only shown if it has been edited).
I know I can compare created_at and updated_at to check if the comment
has been edited but it seems like a hit on the db if there are a lot of
comments.

Should I add an edited at boolean to the table and update it after edit?
Or am I as well to just compare created_at and updated_at?

Don’t worry about the hit on the database, bottlenecks are almost
never in the areas you expect when coding. Code it up in the simplest
way possible and worry about efficiency if it actually becomes an
issue. In any case the difference between testing a boolean and
comparing two dates is not likely to be significant.

Colin

Thanks Colin,

solid advice, I’ll just use the comparison and take it from there…

Johnny