我当前正在添加一个客户仪表板,客户可以在其中选择不同的报价。
现在,我想为每次成功付款添加唯一的重定向。
我在想类似的东西:
我的预订控制人
def create
service = Service.find(params[:service_id])
if current_user.admin?
flash[:alert] = "Du kannst nicht dein eigenes Angebot kaufen"
elsif current_user.stripe_id.blank?
flash[:alert] = "Füge eine Zahlungsmehtode hinzu"
return redirect_to payment_method_path
else
@reservation = current_user.reservations.build(reservation_params)
@reservation.service = service
@reservation.price = service.price
if @reservation.Bearbeitung!
flash[:notice] = "Ihre Anfrage wurde erfolgreich versendet"
ReservationMailer.confirm_email_to_guest(@reservation.user, service).deliver
confirm_sms(service, @reservation)
else
charge(service, @reservation)
end
end
redirect_to 'RANDOM URL'
end
我该如何实现?
答案 0 :(得分:1)
设置预定义的路径数组
喜欢-
paths_array = [example_1_path(x), example_2_path(x,y), example_3_path(z)..]
random_path = paths_array.shuffle.first
redirect_to random_path
#redirect_to reservations_path(@reservation) # To redirect to show action.