fixes composed_of for delegated attributes and methods #3807

wants to merge 1 commit into


None yet

7 participants

pnegri commented Nov 30, 2011

composed_of wasnt working for delegated attributes and methods again.

this is my first contribution, can any1 check if its valid?


lest commented Nov 30, 2011

It will be good to have test for it


I am fine with this change but we do need to have a test for it, as @lest said.

pnegri commented Nov 30, 2011

did the tests, but (dont know why), the other tests are getting errors like "stack too deep", maybe i did forgot to do something prior to test preparation. but was not my fault, cant execute the aggregation tests on HEAD/rails too.

anyway, the tests for the delegate and methods are working.


Ah, the stack too deep makes total sense. As the overridden method will probably invoked the composed_of bit.

pnegri commented Nov 30, 2011

ok, then its done?

pnegri commented Dec 5, 2011

Any tip on how to improve those tests?

roshats commented Feb 12, 2012

I made commit and now old and new tests pass. Can I attach code to this pull request without creating new?

pnegri commented Feb 27, 2012

roshats. Submit a Pull request to my Branch and i will update this pull.


Is this still an issue?

pnegri commented May 5, 2012

dont know maybe we need to remerge again and pull


@pnegri @roshats any news about this one?

@edtsech edtsech added a commit to edtsech/rails that referenced this pull request May 26, 2012
@edtsech edtsech Fix stack level to deep issue in #3807. 0448f6c
@pnegri pnegri closed this May 26, 2012
@pnegri pnegri reopened this May 26, 2012

@pnegri could you squash your commits?

pnegri commented Jun 1, 2012

hey guys, any update on that?


If #6743 gets merged, this feature won't be useful.

@pnegri pnegri referenced this pull request Jun 16, 2012

Removing composed_of #6743

@steveklabnik steveklabnik added a commit that closed this pull request Jun 18, 2012
@steveklabnik steveklabnik Removing composed_of from ActiveRecord.
This feature adds a lot of complication to ActiveRecord for dubious
value. Let's talk about what it does currently:

class Customer < ActiveRecord::Base
  composed_of :balance, :class_name => "Money", :mapping => %w(balance amount)

Instead, you can do something like this:

    def balance
      @balance ||=, currency)

    def balance=(balance)
      self[:value] = balance.value
      self[:currency] = balance.currency
      @balance = balance

Since that's fairly easy code to write, and doesn't need anything
extra from the framework, if you use composed_of today, you'll
have to add accessors/mutators like that.

Closes #1436
Closes #2084
Closes #3807
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment