redirect_to != return

后端 未结 6 1405
陌清茗
陌清茗 2020-12-07 22:13

I\'m looking for some clarification regarding the behaviour of redirect_to.

I have this code:

if some_condition
   redirect_to(path_one)         


        
6条回答
  •  半阙折子戏
    2020-12-07 22:52

    It's worth noting there is no need to return unless you have any code after redirect_to, as in this example:

    def show
      if can?(:show, :poll)
        redirect_to registrar_poll_url and return
      elsif can?(:show, Invoice)
        redirect_to registrar_invoices_url and return
      end
    end
    

提交回复
热议问题