Rails : render and exit immediately

前端 未结 2 679
误落风尘
误落风尘 2021-02-03 19:16

Using the omniauth gem, I am forced to define a single route callback for succesful logins, regardless of the provider :

def auth_callback 

        auth_data =          


        
相关标签:
2条回答
  • 2021-02-03 19:54

    Why not specifically call render in those methods?

    def process_one
     # do something then render view for process_one
     render :process_one and return
    end
    

    Rails should detect that you've already run it and not try to render again.

    0 讨论(0)
  • 2021-02-03 19:59

    If you want to return from the chain of methods, e.g.

    def a
      ...
      b
      ...
      render "smth"
    end
    ...
    def b
      ...
      # render from some conditional from here
      ...
    end
    

    will cause AbstractController::DoubleRenderError, which means that you call render twice.

    You can read this article to find out 4 ways to manage such situation.

    0 讨论(0)
提交回复
热议问题