mardi 16 avril 2019

Is it possible to have a one line if with more than one result?

I have a method with an if statement that i want to get onto one line if possible. However one part of the condition has two results - pay later and a redirect_to. Is is possible to have this on one line? It doesnt like the syntax when i do it. (I know this will be very long if on one line)

    def invoice
      if @invoice.reason?
        pay_later
        redirect_to admin_invoices_path, notice: t(".success_delay")
      else
        redirect_to new_admin_invoice_payment_path(@invoice)
      end
    end

Aucun commentaire:

Enregistrer un commentaire