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

Ticket #7638: composed_of_form_helpers_documentation.diff

File composed_of_form_helpers_documentation.diff, 1.1 kB (added by oyam, 1 year ago)
  • activerecord/lib/active_record/aggregations.rb

    old new  
    108108    #  
    109109    # Read more about value objects on http://c2.com/cgi/wiki?ValueObject and on the dangers of not keeping value objects 
    110110    # immutable on http://c2.com/cgi/wiki?ValueObjectsShouldBeImmutable 
     111    # 
     112    # == Using value objects with form helpers 
     113    # 
     114    # Because the form helpers use value_before_typecast for rendering values, the helpers will always render with the raw value 
     115    # rather than the content of value object's to_s method, as one might expect. Because of this, a correct value needs to be 
     116    # supplied to the helper. Example: 
     117    # 
     118    #   <%= input(:product, :price, :value => @product.price.to_s) %> 
    111119    module ClassMethods 
    112120      # Adds reader and writer methods for manipulating a value object: 
    113121      # <tt>composed_of :address</tt> adds <tt>address</tt> and <tt>address=(new_address)</tt> methods.