Not able to use block-setting of attributes via association

I just created a ticket for this issue, but I thought it worth bringing it up here as well:

http://rails.lighthouseapp.com/projects/8994/tickets/248-not-able-to-use-block-setting-of-attributes-via-association

The issue is that you can't set attributes with a block if you do so through an association. So, while the following would set the body of the Post to "body":

Post.create(:title => 'my post') { |p| p.body = "body" }

...this would not:

User.last.posts.create(:title => 'my post') { |p| p.body = "body" }

This ticket could be viewed as an enhancement request, of course, but it seemed like something worth having in 2.1 to me.

My apologies, but I don't have the necessary Rails-internals-fu to add a proper patch with a fix myself.

Thanks, - Trevor

Note that one workaround seems to be:

User.last.posts.new(:title => 'my post') { |p| p.body = "body" }.save

- Trevor

I added a patch to the ticket. Both "create" and "create!" are supported.

Ryan