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/ticke... 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
on 2008-05-23 23:12
on 2008-05-23 23:21
On May 23, 4:12 pm, Trevor Turk <trevort...@gmail.com> wrote: > 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/ticke...... Note that one workaround seems to be: User.last.posts.new(:title => 'my post') { |p| p.body = "body" }.save - Trevor