Form Objects is a solution to handle and process custom requests with custom validations, multi-model requests, etc.
- Forms go under the
app/forms
directory. - Form name should have suffix
Form
(e.g.:app/forms/company_registration_form.rb
file will defineCompanyRegistrationForm
) - Form may encapsulate business logic for processing the request, but for complex cases, it is better to consider separate class around the Command Objects layer.
- Form may have
populate
method where the logic of pre-filling form from a model or other sources can be defined. - Use auxiliary_rails gem.