Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

[Patched] ActiveModel::Serialization Documentation Example Fix

#6245

The documentation for ActiveModel::Serialization begins with an incredibly poor example of how to implement a the ActiveModel#attributes method. The hash generated does not correctly provide the local instance values and it memoizes the result - which, that alone is already a very poor practice.

Reported by Nathaniel Bibler · January 2nd, 2011 @ 02:11 AM

State: committed
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Nathaniel Bibler
    Nathaniel Bibler

    Attached is a patch to remove the memoization from the example, as well as correctly return the attribute value in the generated hash.

    January 2nd, 2011 @ 02:15 AM

  2. Nathaniel Bibler
    Nathaniel Bibler
    • Title changed from ActiveModel::Serialization Documentation Example Fix to [Patched] ActiveModel::Serialization Documentation Example Fix
    • Tag changed from activemodel, documentation, serialization to activemodel, documentation, patch, serialization

    January 2nd, 2011 @ 02:15 AM

  3. Nathaniel Bibler
    Nathaniel Bibler

    Fixed the second example, as well.

    January 2nd, 2011 @ 02:18 AM

  4. Nathaniel Bibler
    Nathaniel Bibler
    • Tag changed from activemodel, documentation, patch, serialization to activemodel, doc, documentation, patch, serialization

    January 2nd, 2011 @ 02:27 AM

  5. Tyler Hunt
    Tyler Hunt

    +1, although ideally the serializers would actually use the values from the attributes hash, rather than just the taking the keys and using #send to get the values.

    January 3rd, 2011 @ 01:13 PM

  6. Santiago Pastorino
    Santiago Pastorino
    • State changed from new to resolved
    • Importance changed from to Low

    Hey Nathaniel, do you mind to go ahead and push that to http://github.com/lifo/docrails ?
    Thanks.

    February 4th, 2011 @ 03:03 PM

  7. Repository
  8. Nathaniel Bibler
    Nathaniel Bibler

    Awesome, glad you liked the patch. Thanks for the commit, Santiago. :)

    February 8th, 2011 @ 01:55 AM

  9. bingbing