plutonium 0.15.7 → 0.15.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +19 -81
  3. data/app/assets/plutonium.css +1 -1
  4. data/docs/.vitepress/config.ts +1 -0
  5. data/docs/guide/getting-started/index.md +4 -1
  6. data/docs/guide/tutorial.md +403 -0
  7. data/docs/index.md +19 -15
  8. data/docs/public/tutorial/plutonium-association-panel.png +0 -0
  9. data/docs/public/tutorial/plutonium-dashboard.png +0 -0
  10. data/docs/public/tutorial/plutonium-login-page.png +0 -0
  11. data/docs/public/tutorial/plutonium-nested-form.png +0 -0
  12. data/docs/public/tutorial/plutonium-posts-dashboard-customized.png +0 -0
  13. data/docs/public/tutorial/plutonium-posts-dashboard.png +0 -0
  14. data/docs/public/tutorial/plutonium-posts-detail-customized.png +0 -0
  15. data/docs/public/tutorial/plutonium-posts-detail.png +0 -0
  16. data/docs/public/tutorial/plutonium-publish-post.png +0 -0
  17. data/lib/generators/pu/core/assets/templates/tailwind.config.js +11 -1
  18. data/lib/generators/pu/extra/colorized_logger/colorized_logger_generator.rb +21 -0
  19. data/lib/generators/pu/extra/colorized_logger/templates/config/initializers/colorized_logger.rb +22 -0
  20. data/lib/generators/pu/gem/standard/standard_generator.rb +1 -1
  21. data/lib/plutonium/core/controllers/authorizable.rb +1 -1
  22. data/lib/plutonium/resource/controller.rb +12 -8
  23. data/lib/plutonium/resource/controllers/authorizable.rb +2 -2
  24. data/lib/plutonium/resource/controllers/presentable.rb +15 -4
  25. data/lib/plutonium/ui/dyna_frame/host.rb +1 -1
  26. data/lib/plutonium/ui/form/concerns/renders_nested_resource_fields.rb +73 -70
  27. data/lib/plutonium/ui/table/resource.rb +1 -1
  28. data/lib/plutonium/version.rb +1 -1
  29. data/package-lock.json +2 -2
  30. data/package.json +1 -1
  31. data/tailwind.config.js +11 -1
  32. data/tailwind.options.js +7 -1
  33. metadata +14 -2
@@ -26,6 +26,7 @@ export default defineConfig(withMermaid({
26
26
  text: "Introduction",
27
27
  items: [
28
28
  { text: "What is Plutonium?", link: "/guide/what-is-plutonium" },
29
+ { text: "Tutorial", link: "/guide/tutorial" },
29
30
  ]
30
31
  },
31
32
  {
@@ -1,7 +1,6 @@
1
1
  # Getting Started with Plutonium
2
2
 
3
3
  <!--
4
- This guide covers getting up and running with Plutonium.
5
4
 
6
5
  After reading this guide, you will know:
7
6
 
@@ -10,6 +9,10 @@ After reading this guide, you will know:
10
9
  - The basic principles of Resource design.
11
10
  - How to quickly generate the starting pieces of a Plutonium application.
12
11
  -->
12
+ This guide covers getting up and running with Plutonium.
13
+ It is intended to be a more detailed guide.
14
+
15
+ If you're interested in a quick start, check out our [tutorial](/guide/tutorial).
13
16
 
14
17
  ## Prerequisites
15
18
 
@@ -0,0 +1,403 @@
1
+ # Building a Blog with Plutonium
2
+
3
+ # Building a Blog with Plutonium
4
+
5
+ > **Quick Links:**
6
+ > - 🔍 [Tutorial Demo](https://github.com/radioactive-labs/plutonium-app)
7
+ > - 📂 [Tutorial Source Code](https://github.com/radioactive-labs/plutonium-app)
8
+
9
+ This tutorial walks through building a blog application using Plutonium. You'll learn how to:
10
+
11
+ - Set up authentication using Rodauth
12
+ - Create a blog feature package
13
+ - Build a dashboard/portal
14
+ - Implement posts and comments
15
+ - Add interactive actions
16
+ - Configure scoping and authorization
17
+
18
+ [Rest of the tutorial content remains exactly the same...]
19
+
20
+ ## Initial Setup
21
+
22
+ Let's start by creating a new Rails application with Plutonium:
23
+
24
+ ```bash
25
+ rails new plutonium_app -a propshaft -j esbuild -c tailwind \
26
+ -m https://radioactive-labs.github.io/plutonium-core/templates/plutonium.rb
27
+ ```
28
+
29
+ This creates a new Rails application with:
30
+ - Propshaft as the asset pipeline
31
+ - esbuild for JavaScript bundling
32
+ - Tailwind CSS for styling
33
+ - Plutonium's base configuration
34
+
35
+ ## Setting Up Authentication
36
+
37
+ Next, let's add authentication using Rodauth:
38
+
39
+ ```bash
40
+ # Generate Rodauth configuration
41
+ rails generate pu:rodauth:install
42
+
43
+ # Generate user account setup
44
+ rails generate pu:rodauth:account user
45
+ rails db:migrate
46
+ ```
47
+
48
+ This sets up:
49
+ - A User model with authentication
50
+ - Login/logout functionality
51
+ - Account verification via email
52
+ - Password reset capabilities
53
+
54
+ ![Plutonium Login Page](/tutorial/plutonium-login-page.png)
55
+
56
+ The key files created include:
57
+ - `app/models/user.rb` - The User model
58
+ - `app/rodauth/user_rodauth_plugin.rb` - Rodauth configuration
59
+ - `app/controllers/rodauth_controller.rb` - Base controller for auth pages
60
+ - Database migrations for users and auth-related tables
61
+
62
+ ## Creating the Blog Feature Package
63
+
64
+ Let's create a dedicated package for our blogging functionality:
65
+
66
+ ```bash
67
+ rails generate pu:pkg:package blogging
68
+ ```
69
+
70
+ This generates a new feature package under `packages/blogging/` with:
71
+ - Base controllers
72
+ - Model and policy base classes
73
+ - Package-specific views directory
74
+ - Engine configuration
75
+
76
+ ## Adding Posts Resource
77
+
78
+ Now we can add our first resource - blog posts:
79
+
80
+ ```bash
81
+ rails generate pu:res:scaffold post user:belongs_to title:string \
82
+ content:text 'published_at:datetime?'
83
+ ```
84
+
85
+ ::: tip
86
+ Unlike Rails, Plutonium generates fields as non-null by default.
87
+ Appending `?` to the type e.g. `published_at:datetime?` makes `published_at` a **nullable** datetime.
88
+ :::
89
+
90
+ When prompted, select the `blogging` feature package.
91
+
92
+ This creates:
93
+ - Post model with associations
94
+ - Policy class with basic permissions
95
+ - Controllers for CRUD operations
96
+ - Database migration
97
+
98
+ The generated post model includes:
99
+ ```ruby
100
+ class Blogging::Post < Blogging::ResourceRecord
101
+ belongs_to :user
102
+ validates :title, presence: true
103
+ validates :content, presence: true
104
+ end
105
+ ```
106
+
107
+ Remember to apply the new migrations:
108
+ ```bash
109
+ rails db:migrate
110
+ ```
111
+
112
+ ## Creating the Dashboard Portal
113
+
114
+ Let's add a portal to manage our blog:
115
+
116
+ ```bash
117
+ rails generate pu:pkg:portal dashboard
118
+ ```
119
+
120
+ When prompted, select `user` for authentication.
121
+
122
+ This creates a new portal package under `packages/dashboard_portal/` with:
123
+ - Portal-specific controllers
124
+ - Resource presentation layer
125
+ - Dashboard views
126
+ - Authenticated routes
127
+
128
+ ## Configure Routes
129
+
130
+ Let's configure our application routes to properly handle authentication and dashboard access:
131
+
132
+ ::: code-group
133
+ ```ruby [app/rodauth/user_rodauth_plugin.rb]
134
+ # ==> Redirects
135
+
136
+ # Redirect to home after login.
137
+ create_account_redirect "/" # [!code --]
138
+ create_account_redirect "/dashboard" # [!code ++]
139
+
140
+ # Redirect to home after login.
141
+ login_redirect "/" # [!code --]
142
+ login_redirect "/dashboard" # [!code ++]
143
+
144
+ # Redirect to home page after logout.
145
+ logout_redirect "/" # [!code --]
146
+ logout_redirect "/dashboard" # [!code ++]
147
+
148
+ # Redirect to wherever login redirects to after account verification.
149
+ verify_account_redirect { login_redirect }
150
+ ```
151
+
152
+ ```ruby [config/routes.rb]
153
+ Rails.application.routes.draw do
154
+ # Other routes...
155
+
156
+ # Defines the root path route ("/")
157
+ # root "posts#index" # [!code --]
158
+ root to: redirect("/dashboard") # [!code ++]
159
+ end
160
+ ```
161
+ :::
162
+
163
+ These changes ensure that:
164
+ - Users are directed to the dashboard after signing up
165
+ - Users are directed to the dashboard after logging in
166
+ - Users are directed to the dashboard after logging out
167
+ - The root URL (`/`) redirects to the dashboard
168
+ - Account verification follows the same flow as login
169
+
170
+ ## Connecting Posts to Dashboard
171
+
172
+ We can now connect our blog posts to the dashboard:
173
+
174
+ ```bash
175
+ rails generate pu:res:conn
176
+ ```
177
+
178
+ Select:
179
+ 1. Source feature: `blogging`
180
+ 2. Resources: `Blogging::Post`
181
+ 3. Portal: `dashboard_portal`
182
+
183
+ This configures the routing and controllers to display posts in the dashboard.
184
+
185
+ ![Plutonium Posts Dashboard](/tutorial/plutonium-posts-dashboard.png)
186
+
187
+ ## Adding Comments
188
+
189
+ Let's add commenting functionality:
190
+
191
+ ```bash
192
+ rails generate pu:res:scaffold comment blogging/post:belongs_to \
193
+ user:belongs_to body:text
194
+
195
+ rails db:migrate
196
+
197
+ rails generate pu:res:conn
198
+ ```
199
+
200
+ ::: tip
201
+ Note the use of the namespaced model in the association `blogging/post`.
202
+
203
+ Plutonium has inbuilt support for handling namespaces, generating:
204
+ ```ruby
205
+ # model
206
+ belongs_to :post, class_name: "Blogging::Post"
207
+
208
+ # migration
209
+ t.belongs_to :post, null: false, foreign_key: {:to_table=>:blogging_posts}
210
+ ```
211
+ :::
212
+
213
+ This creates:
214
+ - Comment model with associations
215
+ - Policy controlling access
216
+ - CRUD interface in dashboard
217
+ - Proper routing configuration
218
+
219
+ ## Customizing the Interface
220
+
221
+ ### Post Table Customization
222
+
223
+ We can customize how posts appear in the table view:
224
+
225
+ ```ruby
226
+ # packages/blogging/app/policies/blogging/post_policy.rb
227
+ def permitted_attributes_for_index
228
+ [:user, :title, :published_at, :created_at]
229
+ end
230
+ ```
231
+
232
+ ![Plutonium Posts Dashboard (Customized)](/tutorial/plutonium-posts-dashboard-customized.png)
233
+
234
+ ### Post Detail View
235
+
236
+ Customize the post detail layout using display grids:
237
+
238
+ ```ruby
239
+ # packages/blogging/app/definitions/blogging/post_definition.rb
240
+ class Blogging::PostDefinition < Blogging::ResourceDefinition
241
+ display :user, class: "col-span-full"
242
+ display :title, class: "col-span-full"
243
+ display :content, class: "col-span-full"
244
+ display :published_at, class: "col-span-full"
245
+ end
246
+ ```
247
+
248
+ ![Plutonium Posts Detail (Customized)](/tutorial/plutonium-posts-detail-customized.png)
249
+
250
+ ## Adding Publishing Functionality
251
+
252
+ Let's add the ability to publish posts:
253
+
254
+ ::: code-group
255
+
256
+ ```ruby [post_definition.rb]
257
+ # packages/blogging/app/definitions/blogging/post_definition.rb
258
+ action :publish,
259
+ interaction: Blogging::Posts::Publish,
260
+ collection_record_action: false # do not show this on the table
261
+ ```
262
+
263
+ ```ruby [publish.rb]
264
+ # packages/blogging/app/interactions/blogging/posts/publish.rb
265
+ module Blogging
266
+ module Posts
267
+ class Publish < ResourceInteraction
268
+ presents label: "Publish Post", icon: Phlex::TablerIcons::Send
269
+ attribute :resource
270
+
271
+ def execute
272
+ if resource.update(published_at: Time.current)
273
+ succeed(resource)
274
+ .with_message("Post was successfully published")
275
+ else
276
+ failed(resource.errors)
277
+ end
278
+ end
279
+ end
280
+ end
281
+ end
282
+ ```
283
+
284
+ ```ruby [post_policy.rb]
285
+ # packages/blogging/app/policies/blogging/post_policy.rb
286
+
287
+ def publish? # [!code ++]
288
+ !record.published_at # [!code ++]
289
+ end # [!code ++]
290
+
291
+
292
+ def permitted_attributes_for_create
293
+ [:user, :title, :content, :published_at] # [!code --]
294
+ [:user, :title, :content] # [!code ++]
295
+ end
296
+ ```
297
+
298
+ :::
299
+
300
+ ![Plutonium Publish Post](/tutorial/plutonium-publish-post.png)
301
+
302
+ ## Adding Comments Panel
303
+
304
+ Enable viewing comments on posts:
305
+
306
+ ::: code-group
307
+
308
+ ```ruby [post.rb]
309
+ # packages/blogging/app/models/blogging/post.rb
310
+ has_many :comments
311
+ ```
312
+
313
+ ```ruby [post_policy.rb]
314
+ # packages/blogging/app/policies/blogging/post_policy.rb
315
+ def permitted_associations
316
+ %i[comments]
317
+ end
318
+ ```
319
+
320
+ :::
321
+
322
+ ![Plutonium Comments Panel](/tutorial/plutonium-association-panel.png)
323
+
324
+ ## Scoping Resources
325
+
326
+ Ensure users only see their own content:
327
+
328
+ ```ruby
329
+ # packages/dashboard_portal/lib/engine.rb
330
+ module DashboardPortal
331
+ class Engine < Rails::Engine
332
+ include Plutonium::Portal::Engine
333
+
334
+ config.after_initialize do
335
+ scope_to_entity User, strategy: :current_user
336
+ end
337
+ end
338
+ end
339
+ ```
340
+
341
+ ## Adding Nested Comments
342
+
343
+ Enable adding comments directly from the post form:
344
+
345
+ ::: code-group
346
+
347
+ ```ruby [post_definition.rb]
348
+ # packages/blogging/app/definitions/blogging/post_definition.rb
349
+ nested_input :comments,
350
+ using: Blogging::CommentDefinition,
351
+ fields: %i[user body]
352
+ ```
353
+
354
+ ```ruby [post.rb]
355
+ # packages/blogging/app/models/blogging/post.rb
356
+ has_many :comments
357
+ accepts_nested_attributes_for :comments # [!code ++]
358
+ ```
359
+
360
+ ```ruby [post_policy.rb]
361
+ # packages/blogging/app/policies/blogging/post_policy.rb
362
+ def permitted_attributes_for_create
363
+ [:user, :title, :content] # [!code --]
364
+ [:user, :title, :content, :comments] # [!code ++]
365
+ end
366
+ ```
367
+
368
+ :::
369
+
370
+ ![Plutonium Nested Comments](/tutorial/plutonium-nested-form.png)
371
+
372
+ ## Running the Application
373
+
374
+ 1. Start the Development server:
375
+ ```bash
376
+ bin/dev
377
+ ```
378
+
379
+ 2. Visit `http://localhost:3000`
380
+
381
+ 3. Create a user account and start managing your blog!
382
+
383
+ ## What's Next?
384
+
385
+ Some ideas for extending the application:
386
+ - Add categories/tags for posts
387
+ - Implement comment moderation
388
+ - Add rich text editing for post content
389
+ - Create a public-facing blog view
390
+ - Add image attachments for posts
391
+ - Implement social sharing
392
+
393
+ ## Conclusion
394
+
395
+ In this tutorial, we've built a full-featured blog application with:
396
+ - User authentication
397
+ - Post management
398
+ - Commenting system
399
+ - Publishing workflow
400
+ - Proper authorization
401
+ - User-scoped content
402
+
403
+ Plutonium helped us quickly scaffold and connect the pieces while maintaining clean separation of concerns through its package system.
data/docs/index.md CHANGED
@@ -17,27 +17,31 @@ hero:
17
17
  link: /guide/what-is-plutonium
18
18
 
19
19
  features:
20
- - title: Pro-Grade CRUD UI
21
- details: Stunning, modern interface with rich field types to build powerful admin panels in minutes
20
+ # Core Value Proposition - Start with the main benefit
21
+ - title: Rich Resource Management
22
+ details: Beautiful, modern interfaces with production-ready components for rapid development
22
23
 
23
- - title: Intelligent Fields
24
- details: Zero-config field detection that matches your Rails models out of the box
24
+ # Core Architecture Features - Foundation pieces
25
+ - title: Built-in Multitenancy
26
+ details: Row-level multitenancy that works out of the box - perfect for SaaS and enterprise apps
25
27
 
26
- - title: Seamless Authentication
27
- details: Use your existing auth or our Rodauth integration - get setup in seconds
28
+ - title: Advanced Authorization
29
+ details: Comprehensive access control built on Action Policy's proven authorization framework
28
30
 
29
- - title: Enterprise Authorization
30
- details: Industrial-strength access control powered by Action Policy's proven framework
31
+ - title: Seamless Authentication
32
+ details: Integrate your existing auth or use our Rodauth integration - ready in seconds
31
33
 
32
- - title: Built-in Multitenancy
33
- details: Row-level multitenancy that just works - perfect for SaaS and enterprise apps
34
+ # Developer Experience Features - How it makes development easier
35
+ - title: Intelligent Fields
36
+ details: Smart field detection with automatic Rails model mapping and zero configuration needed
34
37
 
35
38
  - title: Advanced Nested Resources
36
- details: Complex resource relationships made simple with zero extra configuration
39
+ details: Complex resource relationships made simple through intelligent relationship mapping
37
40
 
38
- - title: Custom Actions
39
- details: Extend your admin panel with incredibly simple custom actions and workflows
41
+ # Extensibility Features - How it grows with your needs
42
+ - title: Extensible Workflows
43
+ details: Add custom actions and business workflows with a simple, declarative API
40
44
 
41
- - title: Complete Builder Control
42
- details: Total flexibility to customize every aspect of your admin UI with elegant builder APIs
45
+ - title: Flexible UI Customization
46
+ details: Customize any aspect of your interfaces with elegant builder APIs
43
47
  ---
@@ -1,12 +1,22 @@
1
1
  const { execSync } = require('child_process');
2
2
  const plutoniumGemPath = execSync("bundle show plutonium").toString().trim();
3
3
  const plutoniumTailwindConfig = require(`${plutoniumGemPath}/tailwind.options.js`)
4
+ const tailwindPlugin = require('tailwindcss/plugin')
4
5
 
5
6
  module.exports = {
6
7
  darkMode: plutoniumTailwindConfig.darkMode,
7
8
  plugins: [
8
9
  // add plugins here
9
- ].concat(plutoniumTailwindConfig.plugins.map((plugin) => require(plugin))),
10
+ ].concat(plutoniumTailwindConfig.plugins.map(function (plugin) {
11
+ switch (typeof plugin) {
12
+ case "function":
13
+ return tailwindPlugin(plugin)
14
+ case "string":
15
+ return require(plugin)
16
+ default:
17
+ throw Error(`unsupported plugin: ${plugin}: ${(typeof plugin)}`)
18
+ }
19
+ })),
10
20
  theme: plutoniumTailwindConfig.theme,
11
21
  content: [
12
22
  `${__dirname}/app/**/*.rb`,
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../lib/plutonium_generators"
4
+
5
+ module Pu
6
+ module Extra
7
+ class ColorizedLoggerGenerator < Rails::Generators::Base
8
+ include PlutoniumGenerators::Generator
9
+
10
+ source_root File.expand_path("templates", __dir__)
11
+
12
+ desc "Set up a colorized logger"
13
+
14
+ def start
15
+ copy_file "config/initializers/colorized_logger.rb"
16
+ rescue => e
17
+ exception "#{self.class} failed:", e
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ return unless Rails.env.development?
4
+
5
+ # Taken from https://gist.github.com/kyrylo/3d90f7a656d1a0accf244b8f1d25999b?permalink_comment_id=5264120#gistcomment-5264120
6
+
7
+ module ColorizedLogger
8
+ %i[debug info warn error fatal unknown].each do |level|
9
+ color = case level
10
+ when :debug then "\e[0;36m" # Cyan text
11
+ when :info then "\e[0;32m" # Green text
12
+ when :warn then "\e[1;33m" # Yellow text
13
+ when :error, :fatal then "\e[1;31m" # Red text
14
+ else "\e[0m" # Terminal default
15
+ end
16
+
17
+ define_method(level) do |progname = nil, &block|
18
+ super(color + (progname || (block && block.call)).to_s + "\e[0m")
19
+ end
20
+ end
21
+ end
22
+ Rails.logger.extend(ColorizedLogger)
@@ -10,7 +10,7 @@ module Pu
10
10
  desc "Set up standardrb"
11
11
 
12
12
  def start
13
- bundle "standardrb"
13
+ bundle "standard", version: ">= 1.35.1"
14
14
  rescue => e
15
15
  exception "#{self.class} failed:", e
16
16
  end
@@ -26,7 +26,7 @@ module Plutonium
26
26
  end
27
27
 
28
28
  def entity_scope_for_authorize
29
- scoped_to_entity? ? current_scoped_entity : nil
29
+ current_scoped_entity if scoped_to_entity?
30
30
  end
31
31
 
32
32
  def verify_authorized
@@ -34,7 +34,7 @@ module Plutonium
34
34
  # Gets the resource class for the controller
35
35
  # @return [ActiveRecord::Base] The resource class
36
36
  def resource_class
37
- return @resource_class if @resource_class.present?
37
+ return @resource_class if @resource_class
38
38
 
39
39
  name.to_s.gsub(/^#{current_package}::/, "").gsub(/Controller$/, "").classify.constantize
40
40
  rescue NameError
@@ -52,7 +52,7 @@ module Plutonium
52
52
  # Returns the resource record based on path parameters
53
53
  # @return [ActiveRecord::Base, nil] The resource record
54
54
  def resource_record
55
- @resource_record ||= current_authorized_scope.from_path_param(params[:id]).first! if params[:id].present?
55
+ @resource_record ||= current_authorized_scope.from_path_param(params[:id]).first! if params[:id]
56
56
  @resource_record
57
57
  end
58
58
 
@@ -125,19 +125,23 @@ module Plutonium
125
125
  # Applies submitted resource params if they have been passed
126
126
  def maybe_apply_submitted_resource_params!
127
127
  ensure_get_request
128
- resource_record.attributes = submitted_resource_params if params[resource_param_key].present?
128
+ resource_record.attributes = submitted_resource_params if params[resource_param_key]
129
129
  end
130
130
 
131
131
  # Returns the current parent based on path parameters
132
132
  # @return [ActiveRecord::Base, nil] The current parent
133
133
  def current_parent
134
- return unless parent_route_param.present?
134
+ return unless parent_route_param
135
135
 
136
136
  @current_parent ||= begin
137
137
  parent_route_key = parent_route_param.to_s.gsub(/_id$/, "").to_sym
138
138
  parent_class = current_engine.resource_register.route_key_lookup[parent_route_key]
139
- parent_scope = parent_class.from_path_param(params[parent_route_param])
140
- parent_scope = parent_scope.associated_with(current_scoped_entity) if scoped_to_entity?
139
+ parent_scope = if scoped_to_entity?
140
+ parent_class.associated_with(current_scoped_entity)
141
+ else
142
+ parent_class.all
143
+ end
144
+ parent_scope = parent_scope.from_path_param(params[parent_route_param])
141
145
  current_parent = parent_scope.first!
142
146
  authorize! current_parent, to: :read?
143
147
  current_parent
@@ -153,7 +157,7 @@ module Plutonium
153
157
  # Returns the parent input parameter
154
158
  # @return [Symbol, nil] The parent input parameter
155
159
  def parent_input_param
156
- return unless current_parent.present?
160
+ return unless current_parent
157
161
 
158
162
  resource_class.reflect_on_all_associations(:belongs_to).find { |assoc| assoc.klass.name == current_parent.class.name }&.name&.to_sym
159
163
  end
@@ -182,7 +186,7 @@ module Plutonium
182
186
  # Overrides parent parameters
183
187
  # @param [Hash] input_params The input parameters
184
188
  def override_parent_params(input_params)
185
- if current_parent.present?
189
+ if current_parent
186
190
  if input_params.key?(parent_input_param) || resource_class.method_defined?(:"#{parent_input_param}=")
187
191
  input_params[parent_input_param] = current_parent
188
192
  end
@@ -112,7 +112,7 @@ module Plutonium
112
112
  #
113
113
  # @return [Hash] default context for the current resource's policy
114
114
  def current_policy_context
115
- {scope: current_parent || entity_scope_for_authorize}
115
+ {entity_scope: current_parent || entity_scope_for_authorize}
116
116
  end
117
117
 
118
118
  # Authorizes the current action for the given record of the current resource
@@ -130,7 +130,7 @@ module Plutonium
130
130
  #
131
131
  # @return [Array<Symbol>] the list of permitted attributes for the current action
132
132
  def permitted_attributes
133
- @permitted_attributes ||= current_policy.send_with_report(:"permitted_attributes_for_#{action_name}")
133
+ @permitted_attributes ||= current_policy.send_with_report(:"permitted_attributes_for_#{action_name}").freeze
134
134
  end
135
135
 
136
136
  # Returns the list of permitted associations for the current resource