fixes composed_of for delegated attributes and methods #3807

wants to merge 1 commit into

7 participants


composed_of wasnt working for delegated attributes and methods again.

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



It will be good to have test for it

Ruby on Rails member

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


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.

Ruby on Rails member

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


Any tip on how to improve those tests?


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


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


Is this still an issue?


dont know maybe we need to remerge again and pull

Ruby on Rails member

@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
Ruby on Rails member

@pnegri could you squash your commits?

Ruby on Rails member

hey guys, any update on that?

Ruby on Rails member

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