Conversation
… order parameters
There was a problem hiding this comment.
Pull request overview
This PR adds form object support to StructuredParams::Params, enabling seamless use with Rails form helpers (form_with/form_for). It introduces a custom model_name class method that strips "Parameters", "Parameter", or "Form" suffixes from class names, a permit class method supporting both API and form-object usage patterns, and instance-level methods (persisted?, to_key, to_model) for Rails form helper compatibility.
Changes:
- Added
model_name,permit,persisted?,to_key, andto_modeltoStructuredParams::Paramsfor Rails form helper integration - Added
.github/copilot-instructions.mddocumenting coding style, RBS annotations, and project-specific guidelines - Added new spec files (
spec/form_object_spec.rb,spec/permit_spec.rb) and test helper classes (spec/support/test_classes.rb)
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
lib/structured_params/params.rb |
Core changes: adds model_name, permit, persisted?, to_key, to_model; updates process_input_parameters to use new permit method |
sig/structured_params/params.rbs |
Auto-generated RBS type file updated to reflect new methods and class ivar |
spec/form_object_spec.rb |
New spec file testing form object behavior, naming, and Rails helper integration |
spec/permit_spec.rb |
New spec file testing the permit class method for both form-object and API contexts |
spec/support/test_classes.rb |
New support file with test helper classes used by the new specs |
spec/spec_helper.rb |
Loads the new support directory |
.github/copilot-instructions.md |
New file documenting project coding conventions and guidelines |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…d form object usage
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This pull request introduces comprehensive support for using
StructuredParams::Paramsas Rails form objects, alongside improvements to parameter permitting and documentation. The changes ensure seamless integration with Rails form helpers (form_with,form_for) by providing the necessary methods and conventions, and update documentation and tests to reflect these capabilities.Form Object Integration
persisted?,to_key,to_model) toParams, enabling compatibility with Rails form helpers. These methods always return values appropriate for non-persisted objects and ensure Rails can use these objects in forms. [1] [2]model_namemethod that removes "Parameters", "Parameter", or "Form" suffixes from the class name, preserving namespaces, so form objects work seamlessly with Rails naming conventions. [1] [2]spec/form_object_spec.rbwith extensive tests verifying form object behavior, including naming, integration with Rails helpers, and validation.Parameter Permitting Improvements
permitclass method toParamsthat supports both API usage (withoutrequire) and form object usage (withrequire), simplifying strong parameter handling for both contexts. [1] [2]permitmethod, ensuring consistent parameter filtering for both APIs and forms.Documentation and Guidelines
.github/copilot-instructions.mdto document coding style, RBS inline annotation usage, configuration, signature generation, and project-specific guidelines for strong parameters and form objects.These changes collectively make
StructuredParams::Paramsa first-class citizen for Rails form objects, improve developer ergonomics, and ensure clear documentation and test coverage.