Based on my current understanding, if I had to describe how the various components of a rails app work together to respond to requests, I would say the following:
1) Routes determine which request URLs map to which controller methods.
2) Controller methods obtain information from the models and pass that information (in the form of global variables) to corresponding view templates.
3) View templates use the data stored in the global variables to construct the final response.
In the above explanation, the relationships between several components are clear and undeniable; namely:
1) routes and controller methods
2) controller methods and view templates
In fact, the above relationships are 1-to-1.
However, the relationship of the model classes to their adjacent component type (i.e. controllers) is not as clear. Yes, the controllers retrieve information from the models, but consider the following:
1) A controller does not necessarily need to retrieve information from a model, as would be the case for a static website.
2) A controller could retrieve information from multiple model classes.
Therefore, would it be accurate to say that models exist slightly more separately from the other components? Would it be accurate to say that, taken together, the model classes make up the back-end of the back-end of your application, whereas the other components (i.e. routes, controller methods, and view templates) compose a tightly-coupled, linear mechanism wherein the controllers dip into the model classes as necessary? And more specifically, would it be accurate to say that, at least in the context of how the rails components actually fit together, there is no natural relationship between any given controller and any given model (e.g. UserController and User)?
Yes, I know rails comes with the "resources" keyword for use in the routes file to generates RESTful routes and that things are often done in a RESTful way in rails. You could say that rails lends itself to the development of RESTful web applications. And in the context of a RESTful application, the model and controller are implicitly related to each other. But that's a description of the REST architectural style. I'm asking about rails. It seems to me that in rails itself, models are only related to controllers to the extent that the model is used in the implementation of the controller's methods - and because code organization in software is arbitrary, those relationships are arbitrary.
I'm thinking about these things because I want to add a way for users to view their own profiles. I already have a User model and a controller and views for displaying information about users. The profile page would display information from the User model, but I don't want to use the same controller or views for the user's own profile as I do for displaying information about other users. So, I plan to create a new controller and views for the profile, but use the User model to retrieve the information that gets displayed. It's an arbitrary decision, much like other arbitrary decisions made when building an app. But it wouldn't be a valid decision if for some reason models and controllers were supposed to remain tightly coupled (e.g. 1-to-1) in rails.
Can anyone confirm or refute what I'm saying?