How to infer the form method for custom objects in Rails
24-Jan-2025 100
Automatically infer the correct HTTP verb in your Rails forms by defining the persisted?
method.Rails is able to automaticaly infer which HTTP verb to use when generating forms for Active Record models in form_with. How can we get the same for our plain old Ruby objects?
Problem
We want to avoid having to explicitly specify the method when rendering a form for our custom Cat object. Active Record objects don’t have to do this, so why do we?!.
How to infer the form method for custom objects in Rails #ruby #rubydeveloper #rubyonrails #infer #method #custom #objects #Rails https://rubyonrails.ba/link/how-to-infer-the-form-method-for-custom-objects-in-rails