Pretty simple post, but any ruby object can be post conifged in a line with somthing like:
User.new(:name => “tony”){|u| u.save}
which is great for active record tests.
Or in a bigger example:
@trip = Trip.new{|t| t.save!}
@invite1 = Invitation.new(:user => users(:aaron),
:status => Invitation::STATUS_MAYBE){|i| i.save}
@invite1 = Invitation.new(:user => users(:aaron),
:status => Invitation::STATUS_MAYBE){|i| i.save}
2 Comments
Why not just use Invitation#create instead?
Good point. A poor choice of examples. I just found it interesting and it illustrates that many methods that you wouldn’t expect have blocks.
Post a Comment