All Projects → LendingHome → active_record-updated_at

LendingHome / active_record-updated_at

Licence: MIT license
Touch `updated_at` by default with calls to `update_all` and `update_column(s)`

Programming Languages

ruby
36898 projects - #4 most used programming language
shell
77523 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to active record-updated at

filtered
Filters ActiveRecord queries in a nice way
Stars: ✭ 28 (+3.7%)
Mutual labels:  activerecord, gem, ruby-on-rails
rails cursor pagination
Add cursor pagination to your ActiveRecord backed application
Stars: ✭ 21 (-22.22%)
Mutual labels:  activerecord, gem, ruby-on-rails
Filterrific
Filterrific is a Rails Engine plugin that makes it easy to filter, search, and sort your ActiveRecord lists.
Stars: ✭ 810 (+2900%)
Mutual labels:  activerecord, ruby-on-rails
Datagrid
Gem to create tables grids with sortable columns and filters
Stars: ✭ 921 (+3311.11%)
Mutual labels:  activerecord, gem
Model probe
Schema introspection for ActiveModel
Stars: ✭ 58 (+114.81%)
Mutual labels:  activerecord, ruby-on-rails
Database consistency
The tool to find inconsistency between models schema and database constraints.
Stars: ✭ 418 (+1448.15%)
Mutual labels:  activerecord, ruby-on-rails
Ransack
Object-based searching.
Stars: ✭ 5,020 (+18492.59%)
Mutual labels:  activerecord, ruby-on-rails
Goldiloader
Just the right amount of Rails eager loading
Stars: ✭ 1,074 (+3877.78%)
Mutual labels:  activerecord, ruby-on-rails
LocalSupport
A directory of local support services and volunteer opportunities
Stars: ✭ 60 (+122.22%)
Mutual labels:  activerecord, ruby-on-rails
Counter culture
Turbo-charged counter caches for your Rails app.
Stars: ✭ 1,397 (+5074.07%)
Mutual labels:  activerecord, gem
Graphql devise
GraphQL interface on top devise_token_auth
Stars: ✭ 100 (+270.37%)
Mutual labels:  activerecord, gem
Active record Events
Manage timestamps in ActiveRecord models
Stars: ✭ 109 (+303.7%)
Mutual labels:  activerecord, ruby-on-rails
Algoliasearch Rails
AlgoliaSearch integration to your favorite ORM
Stars: ✭ 352 (+1203.7%)
Mutual labels:  activerecord, gem
Database validations
Database validations for ActiveRecord
Stars: ✭ 274 (+914.81%)
Mutual labels:  activerecord, ruby-on-rails
Active Record Query Trace
Rails plugin that logs/displays a backtrace of all SQL queries executed by Active Record
Stars: ✭ 785 (+2807.41%)
Mutual labels:  activerecord, ruby-on-rails
Elasticsearch Rails
Elasticsearch integrations for ActiveModel/Record and Ruby on Rails
Stars: ✭ 2,896 (+10625.93%)
Mutual labels:  activerecord, ruby-on-rails
Type scopes
Automatic scopes for ActiveRecord models.
Stars: ✭ 24 (-11.11%)
Mutual labels:  activerecord, ruby-on-rails
rails-countries
Integration between Rails and countries gem.
Stars: ✭ 17 (-37.04%)
Mutual labels:  activerecord, gem
lockup
Lockup Gem
Stars: ✭ 111 (+311.11%)
Mutual labels:  gem, ruby-on-rails
Active reporting
OLAP-like DSL for ActiveRecord-based reporting
Stars: ✭ 83 (+207.41%)
Mutual labels:  activerecord, gem

LendingHome active_record-updated_at

Code Climate Coverage Gem Version

Touch updated_at by default with calls to update_all and update_column(s)

Installation

Add this gem to the project Gemfile.

gem "active_record-updated_at"

Usage

The default ActiveRecord behavior does not touch updated_at when the following are called:

  • ActiveRecord::Base#update_column
  • ActiveRecord::Base#update_columns
  • ActiveRecord::Relation#update_all

We rarely ever have a case to modify data WITHOUT touching updated_at so this gem enables the touching behavior by default. For those rare occasions that we don't want the touching we can wrap these calls in a disable block explicitly:

ActiveRecord::UpdatedAt.disable { User.update_all(role: "member") }

If updated_at is explicitly specified then the UPDATE query is not modified.

# This touches `updated_at` with `Time.current`
User.update_all(role: "member")

# This sets `updated_at` to `1.day.ago`
User.update_all(role: "member", updated_at: 1.day.ago)

# This sets `updated_at` to `NULL`
User.update_all(role: "member", updated_at: nil)

# This doesn't touch `updated_at`
ActiveRecord::UpdatedAt.disable { User.update_all(role: "member") }

Testing

bundle exec rspec

Contributing

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so we don't break it in a future version unintentionally.
  • Commit, do not mess with the version or history.
  • Open a pull request. Bonus points for topic branches.

Authors

License

MIT - Copyright © 2016 LendingHome

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].