compony 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +26 -0
  3. data/Gemfile.lock +3 -3
  4. data/README.md +41 -0
  5. data/Rakefile +2 -2
  6. data/VERSION +1 -1
  7. data/compony.gemspec +5 -5
  8. data/doc/ComponentGenerator.html +1 -1
  9. data/doc/Components.html +1 -1
  10. data/doc/ComponentsGenerator.html +1 -1
  11. data/doc/Compony/Component.html +9 -9
  12. data/doc/Compony/ComponentMixins/Default/Labelling.html +1 -1
  13. data/doc/Compony/ComponentMixins/Default/Standalone/ResourcefulVerbDsl.html +1 -1
  14. data/doc/Compony/ComponentMixins/Default/Standalone/StandaloneDsl.html +6 -6
  15. data/doc/Compony/ComponentMixins/Default/Standalone/VerbDsl.html +1 -1
  16. data/doc/Compony/ComponentMixins/Default/Standalone.html +1 -1
  17. data/doc/Compony/ComponentMixins/Default.html +1 -1
  18. data/doc/Compony/ComponentMixins/Resourceful.html +1 -1
  19. data/doc/Compony/ComponentMixins.html +1 -1
  20. data/doc/Compony/Components/Button.html +1 -1
  21. data/doc/Compony/Components/Destroy.html +1 -1
  22. data/doc/Compony/Components/Edit.html +18 -18
  23. data/doc/Compony/Components/Form.html +316 -90
  24. data/doc/Compony/Components/New.html +18 -18
  25. data/doc/Compony/Components/WithForm.html +94 -19
  26. data/doc/Compony/Components.html +1 -1
  27. data/doc/Compony/ControllerMixin.html +1 -1
  28. data/doc/Compony/Engine.html +1 -1
  29. data/doc/Compony/MethodAccessibleHash.html +1 -1
  30. data/doc/Compony/ModelFields/Anchormodel.html +1 -1
  31. data/doc/Compony/ModelFields/Association.html +1 -1
  32. data/doc/Compony/ModelFields/Attachment.html +1 -1
  33. data/doc/Compony/ModelFields/Base.html +1 -1
  34. data/doc/Compony/ModelFields/Boolean.html +1 -1
  35. data/doc/Compony/ModelFields/Color.html +1 -1
  36. data/doc/Compony/ModelFields/Currency.html +1 -1
  37. data/doc/Compony/ModelFields/Date.html +1 -1
  38. data/doc/Compony/ModelFields/Datetime.html +1 -1
  39. data/doc/Compony/ModelFields/Decimal.html +1 -1
  40. data/doc/Compony/ModelFields/Email.html +1 -1
  41. data/doc/Compony/ModelFields/Float.html +1 -1
  42. data/doc/Compony/ModelFields/Integer.html +1 -1
  43. data/doc/Compony/ModelFields/Percentage.html +1 -1
  44. data/doc/Compony/ModelFields/Phone.html +1 -1
  45. data/doc/Compony/ModelFields/RichText.html +1 -1
  46. data/doc/Compony/ModelFields/String.html +1 -1
  47. data/doc/Compony/ModelFields/Text.html +1 -1
  48. data/doc/Compony/ModelFields/Time.html +1 -1
  49. data/doc/Compony/ModelFields/Url.html +1 -1
  50. data/doc/Compony/ModelFields.html +1 -1
  51. data/doc/Compony/ModelMixin.html +26 -26
  52. data/doc/Compony/NaturalOrdering.html +1 -1
  53. data/doc/Compony/RequestContext.html +1 -1
  54. data/doc/Compony/Version.html +1 -1
  55. data/doc/Compony/ViewHelpers.html +1 -1
  56. data/doc/Compony.html +2 -2
  57. data/doc/ComponyController.html +1 -1
  58. data/doc/_index.html +1 -1
  59. data/doc/file.README.html +42 -1
  60. data/doc/index.html +42 -1
  61. data/doc/method_list.html +122 -98
  62. data/doc/top-level-namespace.html +1 -1
  63. data/lib/compony/component.rb +4 -4
  64. data/lib/compony/component_mixins/default/standalone/standalone_dsl.rb +3 -3
  65. data/lib/compony/components/edit.rb +4 -1
  66. data/lib/compony/components/form.rb +74 -9
  67. data/lib/compony/components/new.rb +4 -1
  68. data/lib/compony/components/with_form.rb +12 -1
  69. data/lib/compony/model_mixin.rb +8 -1
  70. data/lib/compony.rb +1 -1
  71. metadata +5 -5
@@ -264,14 +264,14 @@
264
264
  <pre class="lines">
265
265
 
266
266
 
267
- 92
268
- 93
269
- 94
270
- 95
271
- 96</pre>
267
+ 99
268
+ 100
269
+ 101
270
+ 102
271
+ 103</pre>
272
272
  </td>
273
273
  <td>
274
- <pre class="code"><span class="info file"># File 'lib/compony/model_mixin.rb', line 92</span>
274
+ <pre class="code"><span class="info file"># File 'lib/compony/model_mixin.rb', line 99</span>
275
275
 
276
276
  <span class='kw'>def</span> <span class='id identifier rubyid_feasibility_messages'>feasibility_messages</span><span class='lparen'>(</span><span class='id identifier rubyid_action_name'>action_name</span><span class='rparen'>)</span>
277
277
  <span class='id identifier rubyid_action_name'>action_name</span> <span class='op'>=</span> <span class='id identifier rubyid_action_name'>action_name</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span>
@@ -360,13 +360,6 @@
360
360
  <pre class="lines">
361
361
 
362
362
 
363
- 71
364
- 72
365
- 73
366
- 74
367
- 75
368
- 76
369
- 77
370
363
  78
371
364
  79
372
365
  80
@@ -376,10 +369,17 @@
376
369
  84
377
370
  85
378
371
  86
379
- 87</pre>
372
+ 87
373
+ 88
374
+ 89
375
+ 90
376
+ 91
377
+ 92
378
+ 93
379
+ 94</pre>
380
380
  </td>
381
381
  <td>
382
- <pre class="code"><span class="info file"># File 'lib/compony/model_mixin.rb', line 71</span>
382
+ <pre class="code"><span class="info file"># File 'lib/compony/model_mixin.rb', line 78</span>
383
383
 
384
384
  <span class='kw'>def</span> <span class='id identifier rubyid_feasible?'>feasible?</span><span class='lparen'>(</span><span class='id identifier rubyid_action_name'>action_name</span><span class='comma'>,</span> <span class='label'>recompute:</span> <span class='kw'>false</span><span class='rparen'>)</span>
385
385
  <span class='id identifier rubyid_action_name'>action_name</span> <span class='op'>=</span> <span class='id identifier rubyid_action_name'>action_name</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span>
@@ -429,12 +429,12 @@
429
429
  <pre class="lines">
430
430
 
431
431
 
432
- 109
433
- 110
434
- 111</pre>
432
+ 116
433
+ 117
434
+ 118</pre>
435
435
  </td>
436
436
  <td>
437
- <pre class="code"><span class="info file"># File 'lib/compony/model_mixin.rb', line 109</span>
437
+ <pre class="code"><span class="info file"># File 'lib/compony/model_mixin.rb', line 116</span>
438
438
 
439
439
  <span class='kw'>def</span> <span class='id identifier rubyid_field'>field</span><span class='lparen'>(</span><span class='id identifier rubyid_field_name'>field_name</span><span class='comma'>,</span> <span class='id identifier rubyid_controller'>controller</span><span class='rparen'>)</span>
440
440
  <span class='id identifier rubyid_fields'>fields</span><span class='lbracket'>[</span><span class='id identifier rubyid_field_name'>field_name</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_value_for'>value_for</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='label'>controller:</span><span class='rparen'>)</span>
@@ -490,14 +490,14 @@
490
490
  <pre class="lines">
491
491
 
492
492
 
493
- 102
494
- 103
495
- 104
496
- 105
497
- 106</pre>
493
+ 109
494
+ 110
495
+ 111
496
+ 112
497
+ 113</pre>
498
498
  </td>
499
499
  <td>
500
- <pre class="code"><span class="info file"># File 'lib/compony/model_mixin.rb', line 102</span>
500
+ <pre class="code"><span class="info file"># File 'lib/compony/model_mixin.rb', line 109</span>
501
501
 
502
502
  <span class='kw'>def</span> <span class='id identifier rubyid_full_feasibility_messages'>full_feasibility_messages</span><span class='lparen'>(</span><span class='id identifier rubyid_action_name'>action_name</span><span class='rparen'>)</span>
503
503
  <span class='id identifier rubyid_text'>text</span> <span class='op'>=</span> <span class='id identifier rubyid_feasibility_messages'>feasibility_messages</span><span class='lparen'>(</span><span class='id identifier rubyid_action_name'>action_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>, </span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_upcase_first'>upcase_first</span>
@@ -514,7 +514,7 @@
514
514
  </div>
515
515
 
516
516
  <div id="footer">
517
- Generated on Mon Jun 3 15:20:40 2024 by
517
+ Generated on Tue Jun 11 11:15:54 2024 by
518
518
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
519
519
  0.9.36 (ruby-3.2.2).
520
520
  </div>
@@ -290,7 +290,7 @@
290
290
  </div>
291
291
 
292
292
  <div id="footer">
293
- Generated on Mon Jun 3 15:20:40 2024 by
293
+ Generated on Tue Jun 11 11:15:54 2024 by
294
294
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
295
295
  0.9.36 (ruby-3.2.2).
296
296
  </div>
@@ -931,7 +931,7 @@
931
931
  </div>
932
932
 
933
933
  <div id="footer">
934
- Generated on Mon Jun 3 15:20:40 2024 by
934
+ Generated on Tue Jun 11 11:15:54 2024 by
935
935
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
936
936
  0.9.36 (ruby-3.2.2).
937
937
  </div>
@@ -129,7 +129,7 @@
129
129
  </div>
130
130
 
131
131
  <div id="footer">
132
- Generated on Mon Jun 3 15:20:40 2024 by
132
+ Generated on Tue Jun 11 11:15:54 2024 by
133
133
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
134
134
  0.9.36 (ruby-3.2.2).
135
135
  </div>
@@ -433,7 +433,7 @@
433
433
  </div>
434
434
 
435
435
  <div id="footer">
436
- Generated on Mon Jun 3 15:20:40 2024 by
436
+ Generated on Tue Jun 11 11:15:54 2024 by
437
437
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
438
438
  0.9.36 (ruby-3.2.2).
439
439
  </div>
data/doc/Compony.html CHANGED
@@ -2129,7 +2129,7 @@
2129
2129
  <span class='kw'>end</span>
2130
2130
  <span class='id identifier rubyid_return_value'>return_value</span> <span class='op'>=</span> <span class='id identifier rubyid_block'>block</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span>
2131
2131
  <span class='comment'># Restore previous value
2132
- </span> <span class='id identifier rubyid_keys_to_overwrite'>keys_to_overwrite</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid__new_value'>_new_value</span><span class='op'>|</span>
2132
+ </span> <span class='id identifier rubyid_keys_to_overwrite'>keys_to_overwrite</span><span class='period'>.</span><span class='id identifier rubyid_each_key'>each_key</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_key'>key</span><span class='op'>|</span>
2133
2133
  <span class='const'>RequestStore</span><span class='period'>.</span><span class='id identifier rubyid_store'>store</span><span class='lbracket'>[</span><span class='symbol'>:button_defaults</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_old_values'>old_values</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span>
2134
2134
  <span class='kw'>end</span>
2135
2135
  <span class='comment'># Undefine keys that were not there previously
@@ -2146,7 +2146,7 @@
2146
2146
  </div>
2147
2147
 
2148
2148
  <div id="footer">
2149
- Generated on Mon Jun 3 15:20:40 2024 by
2149
+ Generated on Tue Jun 11 11:15:54 2024 by
2150
2150
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
2151
2151
  0.9.36 (ruby-3.2.2).
2152
2152
  </div>
@@ -114,7 +114,7 @@
114
114
  </div>
115
115
 
116
116
  <div id="footer">
117
- Generated on Mon Jun 3 15:20:40 2024 by
117
+ Generated on Tue Jun 11 11:15:54 2024 by
118
118
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
119
119
  0.9.36 (ruby-3.2.2).
120
120
  </div>
data/doc/_index.html CHANGED
@@ -566,7 +566,7 @@
566
566
  </div>
567
567
 
568
568
  <div id="footer">
569
- Generated on Mon Jun 3 15:20:38 2024 by
569
+ Generated on Tue Jun 11 11:15:52 2024 by
570
570
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
571
571
  0.9.36 (ruby-3.2.2).
572
572
  </div>
data/doc/file.README.html CHANGED
@@ -1305,6 +1305,8 @@ my_button = Compony.button(:index, :users, enabled: -&gt; { |controller| control
1305
1305
  <span class='kw'>end</span>
1306
1306
  </code></pre>
1307
1307
 
1308
+ <p>All fields declared this way are automatically exported as Rails Model attributes. Note that this also means that you should never declare <code>password</code> and <code>password_confirmation</code> as a Compony field, as you will get the ArgumentError “One or more password arguments are required” otherwise. Read more about handling password fields in the section about <code>Compony::Components::Form</code>.</p>
1309
+
1308
1310
  <p>Compony fields provide the following features:</p>
1309
1311
  <ul><li>
1310
1312
  <p>a label that lets you generate a name for the column: <code>User.fields[:first_name].label</code></p>
@@ -1446,6 +1448,45 @@ my_button = Compony.button(:index, :users, enabled: -&gt; { |controller| control
1446
1448
 
1447
1449
  <p>Note that the inputs and schema are two completely different concepts that are not auto-inferred from each other. You must make sure that they always correspond. If you forget to mention a field in <code>schema_fields</code>, posting the form will fail. Luckily, Schemacop’s excellent error messaging will explain which parameter is prohibited.</p>
1448
1450
 
1451
+ <p>Both calls respect Cancancan’s <code>permitted_attributes</code> directive. This means that you can safely declare <code>field</code> and <code>schema_field</code> in a form that is shared among users with different kinds of permissions. If the current user is not allowed to access a field, the input will be omitted automatically. Further, the parameter validation will exclude that field, effectively disallowing that user from submitting that parameter.</p>
1452
+
1453
+ <h4 id="label-Handling+password+fields">Handling password fields</h4>
1454
+
1455
+ <p>When using Rails’ <code>has_secure_password</code> method, which typically generates the attributes accessors <code>:password</code> and <code>password_confirmation</code>, do not declare these two as fields in your User model.</p>
1456
+
1457
+ <p>There are two main reasons for this:</p>
1458
+ <ul><li>
1459
+ <p><code>password</code> and <code>password_confirmation</code> should never show up in lists and show pages, and as these kinds of components tend to iterate over all fields, it’s best to have anything that should not show up there declared as a field in the first place.</p>
1460
+ </li><li>
1461
+ <p>Rails’ <code>authenticate_by</code> does not work when <code>password</code> is declared as a model attribute.</p>
1462
+ </li></ul>
1463
+
1464
+ <p>Instead of making these accessors Compony fields, ignore them in the User model and use the following methods in your Form:</p>
1465
+
1466
+ <pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'><span class='object_link'><a href="Components.html" title="Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Users</span><span class='op'>::</span><span class='const'>Form</span> <span class='op'>&lt;</span> <span class='const'><span class='object_link'><a href="Compony.html" title="Compony (module)">Compony</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Compony/Components.html" title="Compony::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Compony/Components/Form.html" title="Compony::Components::Form (class)">Form</a></span></span>
1467
+ <span class='id identifier rubyid_setup'>setup</span> <span class='kw'>do</span>
1468
+ <span class='id identifier rubyid_form_fields'>form_fields</span> <span class='kw'>do</span>
1469
+ <span class='comment'># ...
1470
+ </span> <span class='id identifier rubyid_concat'>concat</span> <span class='id identifier rubyid_pw_field'>pw_field</span><span class='lparen'>(</span><span class='symbol'>:password</span><span class='rparen'>)</span>
1471
+ <span class='id identifier rubyid_concat'>concat</span> <span class='id identifier rubyid_pw_field'>pw_field</span><span class='lparen'>(</span><span class='symbol'>:password_confirmation</span><span class='rparen'>)</span>
1472
+ <span class='kw'>end</span>
1473
+
1474
+ <span class='comment'># ...
1475
+ </span> <span class='id identifier rubyid_schema_pw_field'>schema_pw_field</span> <span class='symbol'>:password</span>
1476
+ <span class='id identifier rubyid_schema_pw_field'>schema_pw_field</span> <span class='symbol'>:password_confirmation</span>
1477
+ <span class='kw'>end</span>
1478
+ <span class='kw'>end</span>
1479
+ </code></pre>
1480
+
1481
+ <p>In contrast to the regular <code>field</code> and <code>schema_field</code> calls, their <code>pw_...</code> pendants do not check for per-field authorization. Instead, they check whether the current user can <code>:set_password</code> on the form’s object. Therefore, your ability may look something like:</p>
1482
+
1483
+ <pre class="code ruby"><code class="ruby">class Ability
1484
+ # ...
1485
+ can :manage, User # This allows full access to all users
1486
+ cannot :manage, User, [:user_role] # This prohibits access to user_role, thus removing the input and making the parameter invalid if passed anyway
1487
+ cannot :set_password, User # This prohibits setting and changing passwords of any user
1488
+ </code></pre>
1489
+
1449
1490
  <h3 id="label-New">New</h3>
1450
1491
 
1451
1492
  <p>This component is the Compony equivalent to a typical Rails controller’s <code>new</code> and <code>create</code> actions.</p>
@@ -1621,7 +1662,7 @@ my_button = Compony.button(:index, :users, enabled: -&gt; { |controller| control
1621
1662
  </div></div>
1622
1663
 
1623
1664
  <div id="footer">
1624
- Generated on Mon Jun 3 15:20:40 2024 by
1665
+ Generated on Tue Jun 11 11:15:53 2024 by
1625
1666
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1626
1667
  0.9.36 (ruby-3.2.2).
1627
1668
  </div>
data/doc/index.html CHANGED
@@ -1305,6 +1305,8 @@ my_button = Compony.button(:index, :users, enabled: -&gt; { |controller| control
1305
1305
  <span class='kw'>end</span>
1306
1306
  </code></pre>
1307
1307
 
1308
+ <p>All fields declared this way are automatically exported as Rails Model attributes. Note that this also means that you should never declare <code>password</code> and <code>password_confirmation</code> as a Compony field, as you will get the ArgumentError “One or more password arguments are required” otherwise. Read more about handling password fields in the section about <code>Compony::Components::Form</code>.</p>
1309
+
1308
1310
  <p>Compony fields provide the following features:</p>
1309
1311
  <ul><li>
1310
1312
  <p>a label that lets you generate a name for the column: <code>User.fields[:first_name].label</code></p>
@@ -1446,6 +1448,45 @@ my_button = Compony.button(:index, :users, enabled: -&gt; { |controller| control
1446
1448
 
1447
1449
  <p>Note that the inputs and schema are two completely different concepts that are not auto-inferred from each other. You must make sure that they always correspond. If you forget to mention a field in <code>schema_fields</code>, posting the form will fail. Luckily, Schemacop’s excellent error messaging will explain which parameter is prohibited.</p>
1448
1450
 
1451
+ <p>Both calls respect Cancancan’s <code>permitted_attributes</code> directive. This means that you can safely declare <code>field</code> and <code>schema_field</code> in a form that is shared among users with different kinds of permissions. If the current user is not allowed to access a field, the input will be omitted automatically. Further, the parameter validation will exclude that field, effectively disallowing that user from submitting that parameter.</p>
1452
+
1453
+ <h4 id="label-Handling+password+fields">Handling password fields</h4>
1454
+
1455
+ <p>When using Rails’ <code>has_secure_password</code> method, which typically generates the attributes accessors <code>:password</code> and <code>password_confirmation</code>, do not declare these two as fields in your User model.</p>
1456
+
1457
+ <p>There are two main reasons for this:</p>
1458
+ <ul><li>
1459
+ <p><code>password</code> and <code>password_confirmation</code> should never show up in lists and show pages, and as these kinds of components tend to iterate over all fields, it’s best to have anything that should not show up there declared as a field in the first place.</p>
1460
+ </li><li>
1461
+ <p>Rails’ <code>authenticate_by</code> does not work when <code>password</code> is declared as a model attribute.</p>
1462
+ </li></ul>
1463
+
1464
+ <p>Instead of making these accessors Compony fields, ignore them in the User model and use the following methods in your Form:</p>
1465
+
1466
+ <pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'><span class='object_link'><a href="Components.html" title="Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Users</span><span class='op'>::</span><span class='const'>Form</span> <span class='op'>&lt;</span> <span class='const'><span class='object_link'><a href="Compony.html" title="Compony (module)">Compony</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Compony/Components.html" title="Compony::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Compony/Components/Form.html" title="Compony::Components::Form (class)">Form</a></span></span>
1467
+ <span class='id identifier rubyid_setup'>setup</span> <span class='kw'>do</span>
1468
+ <span class='id identifier rubyid_form_fields'>form_fields</span> <span class='kw'>do</span>
1469
+ <span class='comment'># ...
1470
+ </span> <span class='id identifier rubyid_concat'>concat</span> <span class='id identifier rubyid_pw_field'>pw_field</span><span class='lparen'>(</span><span class='symbol'>:password</span><span class='rparen'>)</span>
1471
+ <span class='id identifier rubyid_concat'>concat</span> <span class='id identifier rubyid_pw_field'>pw_field</span><span class='lparen'>(</span><span class='symbol'>:password_confirmation</span><span class='rparen'>)</span>
1472
+ <span class='kw'>end</span>
1473
+
1474
+ <span class='comment'># ...
1475
+ </span> <span class='id identifier rubyid_schema_pw_field'>schema_pw_field</span> <span class='symbol'>:password</span>
1476
+ <span class='id identifier rubyid_schema_pw_field'>schema_pw_field</span> <span class='symbol'>:password_confirmation</span>
1477
+ <span class='kw'>end</span>
1478
+ <span class='kw'>end</span>
1479
+ </code></pre>
1480
+
1481
+ <p>In contrast to the regular <code>field</code> and <code>schema_field</code> calls, their <code>pw_...</code> pendants do not check for per-field authorization. Instead, they check whether the current user can <code>:set_password</code> on the form’s object. Therefore, your ability may look something like:</p>
1482
+
1483
+ <pre class="code ruby"><code class="ruby">class Ability
1484
+ # ...
1485
+ can :manage, User # This allows full access to all users
1486
+ cannot :manage, User, [:user_role] # This prohibits access to user_role, thus removing the input and making the parameter invalid if passed anyway
1487
+ cannot :set_password, User # This prohibits setting and changing passwords of any user
1488
+ </code></pre>
1489
+
1449
1490
  <h3 id="label-New">New</h3>
1450
1491
 
1451
1492
  <p>This component is the Compony equivalent to a typical Rails controller’s <code>new</code> and <code>create</code> actions.</p>
@@ -1621,7 +1662,7 @@ my_button = Compony.button(:index, :users, enabled: -&gt; { |controller| control
1621
1662
  </div></div>
1622
1663
 
1623
1664
  <div id="footer">
1624
- Generated on Mon Jun 3 15:20:39 2024 by
1665
+ Generated on Tue Jun 11 11:15:53 2024 by
1625
1666
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1626
1667
  0.9.36 (ruby-3.2.2).
1627
1668
  </div>