propel_facets 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e5233eaef1c8dc1acd2c631b9117c5b1a13c8deb1997d97a0e5fb294c7c55081
4
- data.tar.gz: 15905b8628b5f2cb805b91ba4e25b36451a23ece1768216f64b0ae4fe964a96e
3
+ metadata.gz: 8764980d8f96e30b33af48655e5f663f462c2a163d414d0dd55122b069454bb8
4
+ data.tar.gz: 8c1169ffe3ffbbe48fff25ef54c26ffe2a2fd81c1c63257bac4eeda9992497d3
5
5
  SHA512:
6
- metadata.gz: 57cf3b84754b71e1c18d45ac31690531ec212f49bc2179eda78fc3e791b01f0e6cf7c2dbf38f99e42765c45dfd1a39b071446a461ceb88a206339f2303a7ac82
7
- data.tar.gz: 461b058e8e4f91e575d83560029b738f873c8dd85744be9c22e1bfd343a8c07b53cf1035229ea0906125c8710c20995c51e4f3c4ed568b408f047e2ca816b6e7
6
+ metadata.gz: 8312227990dd32b4026485fd9e331fea3504019342741511214a33754b8e8c67cbe4ce25817fb4f4d319dcf1e4a4e25e305eab590c96a6a8f860d64343021a8c
7
+ data.tar.gz: 4a8184cff3c9bf000f2b42e71cc7d2fb8f6c00c5b7f6c03a9035eba1079d2820cca44e9518dc86000994b4d475b4dc10d2ddefad3c89e715026889cd1d2f8fd4
data/CHANGELOG.md CHANGED
@@ -14,6 +14,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
14
14
  - Metadata inclusion (pagination, counts, etc.)
15
15
  - Performance logging and optimization tools
16
16
 
17
+ ## [0.2.1] - 2025-01-14
18
+
19
+ ### Fixed
20
+ - **Critical generator bug**: Fixed missing `for_organization` scope in ApplicationRecord installation
21
+ - Install generator now properly adds `for_organization` scope when ApplicationRecord already exists
22
+ - Previously only added ModelFacet includes but not the multi-tenancy scope required by PropelApi controllers
23
+ - Enhanced scope implementation to handle both Organization objects and integer IDs
24
+ - Resolves `NoMethodError: undefined method 'for_organization' for Model:Class` in fresh Rails installations
25
+ - Updated both injection method and template files for consistency
26
+
17
27
  ## [0.2.0] - 2025-09-02
18
28
 
19
29
  ### Added
@@ -92,6 +92,18 @@ module PropelFacets
92
92
  json_facet :short, base: :included, include_as: :reference
93
93
  json_facet :details, base: :short, include_as: :included
94
94
 
95
+ # Organization scoping for multi-tenancy
96
+ scope :for_organization, ->(organization_or_id) {
97
+ case organization_or_id
98
+ when nil
99
+ none # No organization = no access
100
+ when Organization
101
+ where(organization: organization_or_id)
102
+ else
103
+ where(organization_id: organization_or_id)
104
+ end
105
+ }
106
+
95
107
  RUBY
96
108
  end
97
109
  end
@@ -12,8 +12,14 @@ class ApplicationRecord < ActiveRecord::Base
12
12
  json_facet :details, base: :short, include_as: :included
13
13
 
14
14
  # Organization scoping for multi-tenancy
15
- scope :for_organization, ->(organization_id) {
16
- return none if organization_id.blank?
17
- where(organization_id: organization_id)
15
+ scope :for_organization, ->(organization_or_id) {
16
+ case organization_or_id
17
+ when nil
18
+ none # No organization = no access
19
+ when Organization
20
+ where(organization: organization_or_id)
21
+ else
22
+ where(organization_id: organization_or_id)
23
+ end
18
24
  }
19
25
  end
data/lib/propel_facets.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module PropelFacets
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: propel_facets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Propel Team