Reputation: 2221
I am new to RoR, so i don't understand the internal mechanism of interaction between view and controller. In any controller we can see the code like that:
class ProductsController < ApplicationController
end
How does ruby interpreter knows where to get ApplicationController class without any 'require'
statment.
Also, how does our controller knows about all models. I mean we if we have product model we can use in our controller the code like:
Product.find(1);
But how actually controller know about the model class
Upvotes: 2
Views: 420
Reputation: 19969
For models, open a rails console in your app and type:
$LOAD_PATH
you will see that the models class is pretty early. This is how auto_loading in Rails is handled.
For views, there is a views_paths which can be manipulated and is outlined here: http://api.rubyonrails.org/classes/AbstractController/ViewPaths/ClassMethods.html
Upvotes: 2