recourse 7.11.3 → 8.0.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: 6e35c26234c6a52cdd8f81deeabc53416701caa7895494f8cc39e61169d469c2
4
- data.tar.gz: 0b98268a91af045f9266a0bf3a6d68cd107b0a733111968675d1ef21704c78c1
3
+ metadata.gz: 7de35fdbec1f8879c4fb6636bf023bd6ed9e585b3d63fc95c0d76c4f0c36fa49
4
+ data.tar.gz: 5e3a1779c3153d4089d2039f074525986963bbc77a5ff6827995dffed74565cd
5
5
  SHA512:
6
- metadata.gz: d00986e3679e75328b6f1e946fc60145b9a19a5faf2e6829523242b6a28800474d5bcd4de838ca4718f0e69b7d5bef618b37c71e9a0d94eda3de9e40a88ad6bc
7
- data.tar.gz: 18826349bd88037bde697715eff5dd68f6e39d0ce0ff937118062cd6997721f75b4928bbf2174da3231ffd4356aab7e0c1913ecc614d05bea18e00514224e362
6
+ metadata.gz: 62dcf7cd0da6acb1af4925cebdc9b9186cd28984d19979acfdbaae7642c697bb77ace967cf1fe247dc3220e187f54d45c5ee80a199880d90041788d2f14d8c1b
7
+ data.tar.gz: dda6c4c65b5d3e72b56bdea47101f979d5d9f6a0c0452b53b5e1d655431d2cf4f238149b20bdd0b6dac9b000bc600d5474a4cfa8b7ac32ac01ae5e57bd55816c
data/CHANGELOG.md CHANGED
@@ -7,6 +7,26 @@ For more information about changelogs, check [Keep a Changelog](http://keepachan
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## 8.0.1 - 2026-10-14
11
+
12
+ * [FIX] Guard the screens with `prepend_before_action`, not `before_action`
13
+
14
+ Since 8.0.0 a record's pages look it up through `recourse_relation` before any
15
+ `before_action` of the host's runs, so a relation reading who is signed in -- an admin's
16
+ own chats -- found nobody and raised. The README, the guides and the comments now say
17
+ `prepend_before_action :authenticate!`, which runs the guard first.
18
+
19
+ ## 8.0.0 - 2026-10-14
20
+
21
+ * [BREAKING] A record's own pages find it among the rows `recourse_relation` lists
22
+
23
+ `show`, `edit`, `update` and `destroy` looked a record up by id across the whole model,
24
+ so a host that narrowed its table -- an admin's own chats, a team's memos -- still let
25
+ anybody read, edit or delete a row the table left out, by typing its id. The record is
26
+ now found through `recourse_relation`, and one the relation leaves out is not found. A
27
+ host whose relation filters out records that should still have pages of their own, or
28
+ selects columns a form cannot save back, finds them in a controller of its own.
29
+
10
30
  ## 7.11.3 - 2026-10-05
11
31
 
12
32
  * [FIX] A host without Action Cable draws every index
data/README.md CHANGED
@@ -14,10 +14,10 @@ gem install recourse
14
14
 
15
15
  ```ruby
16
16
  # Gemfile
17
- gem 'recourse', '~> 7.0'
17
+ gem 'recourse', '~> 8.0'
18
18
  ```
19
19
 
20
- `~> 7.0` follows Semantic Versioning: `bundle update` takes every 7.x and never a
20
+ `~> 8.0` follows Semantic Versioning: `bundle update` takes every 8.x and never a
21
21
  breaking change. Rails 8.1 and Ruby 3.2 are the minimum; the pages need Turbo, which
22
22
  `turbo-rails` brings, and nothing else in the host. Everything a page is styled and
23
23
  scripted by — Bootstrap 6, its icons, Turbo, Stimulus and the controllers behind these
@@ -168,13 +168,18 @@ which the host defines to put behavior above every screen at once:
168
168
 
169
169
  ```ruby
170
170
  class RecoursesController < Recourse::BaseController
171
- before_action :authenticate!
171
+ prepend_before_action :authenticate!
172
172
  end
173
173
  ```
174
174
 
175
+ `prepend_before_action`, so the guard runs before the gem's own: a record's pages look
176
+ it up through `recourse_relation`, and a relation that reads who is signed in finds
177
+ nobody yet if the guard comes after.
178
+
175
179
  A controller the app already defines is left alone, and one line of it is usually
176
180
  enough: `recourse_relation` puts a scope of your own behind a table the gem draws
177
- whole, and `find_resource` finds a singular record the parent names no association for.
181
+ whole, and behind the pages of each record in it, and `find_resource` finds a singular
182
+ record the parent names no association for.
178
183
 
179
184
  ## Step 5. Enjoy the extras
180
185
 
@@ -4,13 +4,16 @@ module Recourse
4
4
  module ResourceResolution
5
5
  private
6
6
 
7
+ # A record with an id is found among the rows `recourse_relation` lists, so a host
8
+ # that narrows its table narrows the record's own pages with it: a row the table
9
+ # leaves out is not found, rather than read, edited or deleted under that route.
7
10
  # A singular resource is reached with no id — `/places/5/memo` names the record by
8
11
  # the path it hangs off rather than by a key of its own — so it is read off the
9
12
  # parent instead, under the name the route already gives it. Where the parent has
10
13
  # no association of that name the record is still the host's to find, in a
11
14
  # controller of its own.
12
15
  def find_resource
13
- return assign resource_class.find(params.expect(:id)) if params.key? :id
16
+ return assign recourse_relation.find(params.expect(:id)) if params.key? :id
14
17
  return unless singular_reflection
15
18
 
16
19
  record = @recourse_parent.association(singular_reflection.name).reader
@@ -1,7 +1,7 @@
1
1
  module Recourse
2
2
  # Everything a recoursed screen does, in a class of its own so a host can put
3
3
  # its own behavior above it — `class RecoursesController < Recourse::BaseController`
4
- # with a `before_action :authenticate!` guards every screen the gem serves.
4
+ # with a `prepend_before_action :authenticate!` guards every screen the gem serves.
5
5
  class BaseController < ApplicationController
6
6
  include Pagy::Method, Positioned, AttachmentResolution, AttachmentWriting,
7
7
  Landing, Paging, ListResolution, ParameterResolution, ParentNaming,
@@ -85,8 +85,9 @@ module Recourse
85
85
  @recourse_model.recourse_broadcast if @recourse_model.respond_to? :recourse_broadcast
86
86
  end
87
87
 
88
- # The rows the index lists, before the search, the sort and the page reach them:
89
- # every row of the model, narrowed by the parent a nested route names. The one thing
88
+ # The rows the index lists, before the search, the sort and the page reach them,
89
+ # and the only rows a record's own pages find: every row of the model, narrowed by
90
+ # the parent a nested route names. The one thing
90
91
  # a host overrides to put a scope of its own behind a screen the gem draws whole —
91
92
  # `def recourse_relation = County.with_boosts_for(@recourse_parent)`. Private, so
92
93
  # overriding it adds a query and never an action.
@@ -1,6 +1,6 @@
1
1
  # The superclass every recoursed controller gets, and what puts its templates
2
2
  # under `recourses/`. A host defines this class itself — its `app/controllers`
3
- # comes first — to put a `before_action` of its own above every screen.
3
+ # comes first — to put a `prepend_before_action` of its own above every screen.
4
4
  class RecoursesController < Recourse::BaseController
5
5
  # Empty on purpose: the behavior is the base class, so a host redefining this
6
6
  # one loses none of it.
@@ -1,4 +1,4 @@
1
1
  module Recourse
2
2
  # Version of the gem, read by the gemspec and by hosts checking compatibility.
3
- VERSION = '7.11.3'
3
+ VERSION = '8.0.1'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recourse
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.11.3
4
+ version: 8.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - claudiob
@@ -296,7 +296,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
296
296
  - !ruby/object:Gem::Version
297
297
  version: '0'
298
298
  requirements: []
299
- rubygems_version: 4.0.3
299
+ rubygems_version: 4.0.20
300
300
  specification_version: 4
301
301
  summary: A routes.rb DSL that mounts ready-made resource screens.
302
302
  test_files: []