ActiveRecord Where Assoc
PaperTrail
Our great sponsors
ActiveRecord Where Assoc | PaperTrail | |
---|---|---|
8 | 18 | |
208 | 6,693 | |
- | 0.4% | |
6.0 | 5.9 | |
6 months ago | 3 months ago | |
Ruby | Ruby | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
ActiveRecord Where Assoc
-
EXISTS clause for active record
I’ve been using the activerecord_where_assoc gem for this. I think it’s API is more natural than this proposal.
-
My new gem lets you follow associations when doing ActiveRecord queries. Here's an intro for follow_assoc.
Your examples using joins would return duplicated Sections. That might force you to add a distinct. I personally find it wrong to do a distinct in a scope just to be able to make the condition I want the scope to do. It's a hidden side effect that could cause problem elsewhere and it's unexpected from the name of the scope. I made a gem to deal with that situation: where_assoc. There is definitely an overlap between both gem.
-
Rails 6.1 adds query method associated to check for the association presence
Assuming that ... was indicating some form of annoyance with that distinct, you might want to take a look at activerecord_where_assoc
-
Rails 6.1.1 allows `where` to reference associations via joined table alias names.
For those interested, the example uses this gem: activerecord_where_assoc
-
Active Record: x.includes(y): y was not recognized for preload
Here is an introduction to the gem.
PaperTrail
-
historical data and "point in time" data modeling techniques, advice.
if the source (web) application makes their own audit tables. ex: our ruby on rails application uses the paper-trail gem
-
Best rails tools to automatically handle logging of things like all a user's actions, or changes to a record in a module - primarily for audit purposes.
Start with https://github.com/paper-trail-gem/paper_trail
-
Inventory/Sales Management module built on a Rails app - what would be the best way to "version" updates made against an SKU.
We use paper_trail for this
-
is there a gem for tracking adhoc rails console changes
I think you could use that in conjunction with the paper_trail gem, as /u/GreenCalligrapher571 mentioned, which is also a good suggestion. As an additional note, when changing records in production while using the paper_trail gem, I suggest wrapping your database-mutating statements executed in the rails console within a whodunnit block, so PaperTrail.request(whodunnit: 'Dorian Marié') { widget.update name: 'Wibble' } or something rather than just widget.update name: 'Wibble'. Or, if you have some sort of issue-tracking / ticketing system, you could set the whodunnit value to the ticket number or whatever, and then anyone who wants to know why the records are in the state they're in can consult that ticket, which hopefully has additional relevant context.
-
History Tracking With Postgres
For a while we did this using the paper-trail gem. This was a very simple way to add a few lines of code to keep track of all of the changes made to an ActiveRecord model. But it came with one drawback. Every change to the data had to be done through ActiveRecord. There are often times when this makes an app vulnerable to a race condition. I’ll use a contrived example so as not to share any real code from our client’s app.
-
Adding soft delete to a Phoenix Commanded (CQRS) API
In most designs, this would probably not be possible unless a table tracking extension is being used in an ORM. Even with change tracking enabled through extensions like paper trail or Django simple history, it can be tricky to restore deleted entities. Object tracking would need to have been enabled before it is needed to ensure the data is still around to be restored.
- Looking for a Rails Gem that Audits Manual Database Changes
-
Temporality/time-travelling in DB with ActiveRecord?
Maybe you are looking for the papertrail gem? https://github.com/paper-trail-gem/paper_trail
- Looking for an observer gem
What are some alternatives?
Ruby JSON Schema Validator - Ruby JSON Schema Validator
Audited - Audited (formerly acts_as_audited) is an ORM extension that logs all changes to your Rails models.
Enumerize - Enumerated attributes with I18n and ActiveRecord/Mongoid support
Paranoia - acts_as_paranoid for Rails 5, 6 and 7
ActsAsTree - ActsAsTree -- Extends ActiveRecord to add simple support for organizing items into parent–children relationships.
Logidze - Database changes log for Rails
activerecord_json_validator - 🔩 ActiveRecord::JSONValidator makes it easy to validate JSON attributes against a JSON schema.
mongoid-history - Multi-user non-linear history tracking, auditing, undo, redo for mongoid.
ActsAsParanoid - ActiveRecord plugin allowing you to hide and restore records without actually deleting them.
manyfold - A self-hosted digital asset manager for 3d print files. Previously named "VanDAM"
Discard - 🃏🗑 Soft deletes for ActiveRecord done right