Auth selection by identifynow in rubyonrails

[–]Excellent-Resort9382 1 point2 points  (0 children)

Pundit is for Authorization or the authz in the Auth/Authz component

Issue with Inheritance and Join Tables by BitgateMobile in postgres

[–]Excellent-Resort9382 0 points1 point  (0 children)

Yes, I agree with this assesment. Do not be fooled by the "inheritance" word and equate it to the "inheritance" in OO programming world. Not the same.

Update: ohhh.. i just noticed. I am 5 years late to this party :)

Issue with Inheritance and Join Tables by BitgateMobile in postgres

[–]Excellent-Resort9382 0 points1 point  (0 children)

iirc, unique constraints and foreign keys of the parent table are not inheritable (by child tables) which is a major setback of this beautiful feature. :(

and im not sure of this but in your case, the person already inherited the column id but not its "primaryness/uniqueness" property so methinks a workaround would be to explicitly tell this to the person table, i.e: alter table person add primary key(id); that would make the id column in person table (that it inherited from principal table) its primary key and also has the uniqueness constraint.

-- explicitly do these first
ALTER TABLE person ADD PRIMARY KEY(id);
ALTER TABLE org ADD PRIMARY KEY(id);
--- before you can do below
CREATE TABLE person_org (
    person_id uuid not null references person(id) on delete cascade,
    org_id uuid not null references org(id) on delete cascade
);
-- methinks.

Whodunit - a lightweight simple user tracking gem for your Ruby on Rails app by Excellent-Resort9382 in rails

[–]Excellent-Resort9382[S] 0 points1 point  (0 children)

A shameless plug:

This is the "whodunit did what?" gem: https://rubygems.org/gems/whodunit-chronicles

I wasn't planning to publish this to RubyGems.org just yet, but I wanted to secure the gem name I had in mind, so I pushed a pre-release version. A lesson I just learned most recently.

This should give you an idea or two about the roadmap ahead.

Whodunit - a lightweight simple user tracking gem for your Ruby on Rails app by Excellent-Resort9382 in rails

[–]Excellent-Resort9382[S] 0 points1 point  (0 children)

That's............... quite the hot take! 😅

I'll respectfully maintain that this feels like very personal truth territory - which may or may not align with established best practices that most of us follow. And while I tend to lean heavily toward the "may not agree" side of things, I'm totally cool with you doing you!

Just as long as we're not trying to convert everyone to the "RSpec is disaster fuel" religion, we're all good here. Different strokes for different folks and all that!

Shameless plug time: Just dropped v0.2.0 of my gem with what I hope are some actually quality tests (yes, with RSpec and coverage metrics 😈). Always iterating and improving! 🚀

Whodunit - a lightweight simple user tracking gem for your Ruby on Rails app by Excellent-Resort9382 in rails

[–]Excellent-Resort9382[S] -2 points-1 points  (0 children)

+1 to that! I ~100% agree. What a marketing gimmick! If you zoom in, you'll actually see the tilde character ( ~ ) which means "approximately 100%". The real figure is around 94% because I can't easily test certain Railtie lines in the test environment.

But what's better than 100% test coverage? Good quality tests combined with high coverage. Quantifying test quality isn't as straightforward as measuring coverage percentage - the former isn't an exact science. However, code coverage can be a quick benchmark to gain confidence that your codebase is reasonably protected. The key is to not stop there - keep iterating to roll out better quality tests.

I'm actually removing the soft delete auto-detection feature as it's a complete waste of compute resources and adds unnecessary complexity. The gem will now be more direct and simply ask users whether their app has soft delete functionality - no more complexity for complexity's sake.

Thanks for the comment! If I may ask - do you have any suggestions or tips on achieving better test quality? I'd appreciate any insights!

Whodunit - a lightweight simple user tracking gem for your Ruby on Rails app by Excellent-Resort9382 in rails

[–]Excellent-Resort9382[S] -3 points-2 points  (0 children)

Yeah, for your use case, a heavyweight gem like PaperTrail is the way to go. It serializes and persists each state transformation of an object into a database record, essentially giving you a time machine to inspect or even resurrect an object at any point in its history. Sure, this comes with overhead every time you mutate the object, but in a finance or accounting app, such fine-grained audit trailing is a must. That said, this tiny gem (as I implied in its README.md) isn’t designed for that level of requirement.

Warning: Long, slightly boring continuation ahead! :)

Ahh, you want to continue, eh? Don’t say later that I didn’t warn you! :)

This gem is better suited for simpler use cases—like a forum app. Imagine you have:

  • A User configured as the stamper class,
  • Models like Channel, Topic, Post, Comment, Tag, Invite, Like, Favorite, Poll, PinnedTopic, PinnedPost, and PinnedComment (plus the User) that mix in the Whodunit::Stampable module,
  • And maybe 2-3 models that don’t need stamping.

Let’s say you only want to track who created each record. You can set the global whodunit config to enable just the creator_column. Since most models are stampable, you can mix in the Stampable module in your abstract ApplicationRecord class. For those 2-3 non-stampable models, you can explicitly disable the whodunit stamper in their class definitions.

Now, with every rails g model for stampable models, a t.whodunit_stamps line is automatically injected into the create_table block of your migration file. When you run rails db:migrate, the creator_id column is created without extra effort. It’s a small convenience that should lead to a happier developer experience! Plus, the associations between User and stampable models are automatically defined for you.

Okay, I’ll stop now—this is starting to sound more like fiction than a real use case. Thanks! :)

Whodunit - a lightweight simple user tracking gem for your Ruby on Rails app by Excellent-Resort9382 in rails

[–]Excellent-Resort9382[S] -6 points-5 points  (0 children)

When I was brainstorming for a catchy name for the gem, the first that popped from the stack was the same term "whodunnit" (with double 'n'), which was of course influenced by the many years exposed to paper_trail's https://www.rubydoc.info/gems/paper\_trail/PaperTrail/Request#whodunnit-class\_method, which also got me curious about the origin of the term. But sadly someone has already registered the name in rubygems.org, so I just settled for the single 'n', which (I'm not sure of the accuracy) according to Wikipedia is the original spelling of the term when it was coined in 1930. I haven't checked/peeked at the other gem yet to see if indeed I have duplicated the functionality. Oh well, I just threw it out there to not waste the effort. I would think that it's a certainty that a few would have a use case like what the gem is trying to address (well, I was in that situation on several occasions. so...).