Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #7638 (new defect)

Opened 1 year ago

Last modified 1 year ago

[PATCH] Implications of composed_of with form helpers should be documented

Reported by: oyam Assigned to: core
Priority: normal Milestone: 2.x
Component: ActiveRecord Version: edge
Severity: minor Keywords: docs
Cc:

Description

The form helpers such as input() and text_field() use value_before_typecast to display a value. (See #215, #229, #5427, #6908 for reasons why) This causes problems when combined with models that use composed_of with one to one aggregated columns representing simple values.

For example, if a column is composed_of a Money class, but the Money class uses cent values internally and in the database, creating a input box with the helper will yield a input box with the cent value, rather than the value that would be returned by calling to_i/to_f/to_s on instance of the Money class returned by model.attribute.

Given the reasons given in the above mentioned tickets, the implications (or at least warning) of using the form helpers with the combination with composed_of should be mentioned in the composed_of documentation. A simple and reasonable workaround for this is supplying a value in the helpers. Ie. <%= input(:object, :method, :value => @object.method.to_s %>

Attachments

composed_of_form_helpers_documentation.diff (1.1 kB) - added by oyam on 02/25/07 00:28:09.

Change History

02/25/07 00:28:09 changed by oyam

  • attachment composed_of_form_helpers_documentation.diff added.

02/25/07 00:28:51 changed by oyam

  • summary changed from Implications of composed_of with form helpers should be documented to [PATCH] Implications of composed_of with form helpers should be documented.

03/10/07 02:19:27 changed by josh

  • keywords set to docs.