On 3 May 2016 at 16:26, Johnny Stewart <lists@ruby-forum.com> 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
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLvScThAXmgZWsBQThXnKkuxFuZSi7jMt9X%2BBw7BqGPnTQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment