Skip to content

Tag Archives: snippets

new has_a block

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}