Project

General

Profile

Actions

Defect #28243

closed

Principal.not_member_of scope does not accept ActiveRecord::Relation

Added by Anonymous about 6 years ago. Updated about 1 month ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Accounts / authentication
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Affected version:

Description

Principal model has the following two scopes: member_of and not_member_of, both of them expect project or collection of projects as an argument. The problem is that given

projects = Project.where(:name => 'My Project')
you'll get correct results from
Principal.member_of(projects)
, but an exception will be thrown if you'll try to run
Principal.not_member_of(projects)
. That's because not_member_of puts its argument into an array if it's not a subclass of Array (which Project::ActiveRecord_Relation is not, though it knows how to #map).

I think one should be able to call both member_of and not_member_of with any kind of project collection, not just Array, and both of them should process arguments in the same way. So I provide a patch for that.


Files

principal.diff (2.93 KB) principal.diff Anonymous, 2018-02-25 20:04
28243.patch (1.17 KB) 28243.patch Go MAEDA, 2024-02-05 13:43
Actions #1

Updated by Go MAEDA about 1 month ago

  • File 28243.patch 28243.patch added
  • Tracker changed from Patch to Defect
  • Subject changed from Consistent interface for Principal.member_of and not_member_of to Principal.not_member_of scope does not accept ActiveRecord::Relation
  • Category set to Accounts / authentication
  • Status changed from New to Confirmed
  • Target version set to 6.0.0

Setting the target version to 6.0.0.

Actions #2

Updated by Go MAEDA about 1 month ago

  • Status changed from Confirmed to Closed
  • Assignee set to Go MAEDA

Committed the fix in r22697.

Actions

Also available in: Atom PDF