I'm learning Ruby on Rails currently and I'm wondering when an instance of a controller class is created. An instance for each action request? Or one instance that is shared between one client's requests?
I can see there are instance variables in the controller class and they are shared with the view, so I think that a controller instance is created on each action request. Am I right?
Yes, each http request from a client will create a new controller instance and call that action method on it. The controller instance variables will be accessible to the view.
Check rails guides for more detail: http://guides.rubyonrails.org/action_controller_overview.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With