Slide 106
Slide 106 text
Passsing code through
%h3 Coupon Code
= text_field_tag :coupon_code
def create
PurchasesOrder.new(
params[:trip_id], params[:hotel_id], params[:activity_id],
params[:length_of_stay], params[:coupon_code]).run
redirect_to :root
end
def initialize(trip_id, hotel_id, activity_ids, length_of_stay, code)
@trip_id, @hotel_id, @activity_ids = trip_id, hotel_id, activity_ids
@length_of_stay = length_of_stay
@code = code
end
def coupon_code
@coupon_code ||= CouponCode.find_by_code(@code)
end
def add_line_item(buyable, unit_price, amount, calculator_class)
OrderLineItemFactory.new(order, buyable, unit_price,
amount, coupon_code, calculator_class).run
end