Ticket #398 (closed enhancement: fixed)

Opened 9 months ago

Last modified 9 months ago

[PATCH] Allow form_for in merb_helpers to be used with non-AR model objects

Reported by: paul.dl..@gmail.com Assigned to: rogelio.samo..@gmail.com
Priority: major Milestone: The Future
Component: Plugins Keywords:
Cc:

Description

Currently form_for in merb_helpers does not work with objects that are no ActiveRecord? models. It fails when trying to address the method new_record? and errors. While a class can implement these to get this functionality it is rather heavy to do so if functionality like the error reporting is not needed. The attached patch checks to see if the object responds to the new_record? and errors methods before calling them. In the case of new_record? this is used to determine whether or not to do a post or put. I have made the default post with the assumption that if the distinction between a create/update is warranted the model object can implement new_record? to provide this information (please correct if this is not reasonable).

If for some reason this patch is not desirable it would be helpful to at least keep the checks for 'errors' and mandate that new_record? be implemented. This is a reasonable approach whereas 'errors' is too AR specific IMO.

Attachments

allow_form_for_with_non_ar_models.diff (2.6 kB) - added by paul.dl..@gmail.com on 01/04/08 13:42:06.

Change History

01/04/08 13:42:06 changed by paul.dl..@gmail.com

  • attachment allow_form_for_with_non_ar_models.diff added.

01/05/08 12:27:18 changed by rogelio.samo..@gmail.com

  • owner set to rogelio.samo..@gmail.com.

01/05/08 12:41:41 changed by rogelio.samo..@gmail.com

  • status changed from new to closed.
  • resolution set to fixed.

(In [1171]) - Allows form_for in merb_helpers to be used with non-AR model objects. closes #398 [paul.dl..@gmail.com]