Reputation: 4593
So I am reading this mannings book, where it is mentioned that. You represent your instance methods with #. So in Rails, when you point some route to 'controller#action
. Clearly action is an instance method, But I did not create any object for the controller class, how this has been taken care of?
Some one told me that, every request creates a new controller object, but I am not sure about it. If that is the case, there will be too many objects in the RAM I feel.
Can someone point me to some source on this topic. I could not find them by googling, and there are no similar questions in SO
Upvotes: 0
Views: 71
Reputation: 84114
To quote the action controller guide
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
Many thousands of objects are allocated for each request. While reducing that is an ongoing area of work, 1 controller instance per request is not a problem.
Upvotes: 1