Rails controller lifecycle

前端 未结 1 1637
鱼传尺愫
鱼传尺愫 2021-02-07 03:06

I want to know a little about the object lifecyle in rails, can I count on new instance per request?, Is it true to say that each web request creates a new controller instance?(

相关标签:
1条回答
  • 2021-02-07 03:53

    Yes, you can rely on a fresh controller instance per request.

    RailsGuides:

    When your application receives a request, the routing will determine which controller and action to run, then Rails creates an instance of that controller and runs the method with the same name as the action.

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