implement begin/resuce in affiliate.rb and assignment.rb