Newer to programming, but I have accomplished some neat stuff. But given my nontraditional approach, I sometimes get frustrated and confused with the "conventional" teachings that involve a lot of assumptions.
So I have been learning rails, and like its structure, but some of the terminology is confusing me, and I have tried to understand it, but cant wrap my head around it. A lot of people keep refering me to the RailsGuides on Layouts and rendering, but I dont fully understand it, and think it lacks a broader context of the overall rails structure.
So, do you know any rails explanation sites/docs/videos/books that describe the overall processes and terminology, and more specifically, ones that address how layouts, renders, partials, and views work, relative to the rails processing?
Specifics:
The terminology gets confusing when trying to understand them in relation to one another. Take for instance the PJAX RailsCast, Bates explicitly shows that their is a difference between the layout and the template. As I am trying to accomplish this via this SO question, I am lost in the conventional structure and naming of files and their function (not everyone, just the ones that seem to be overloaded in naming).
Take for instance the applicaiton.html.erb
file within views/layouts
. Its file path location tells me that it is a "layout", but what about the _navigation.html.erb
and _left.html.erb
and the _right.html.erb
etc.... that are also located in the views/layouts
since all pages share these, the are in the same level as application.html.erb
But these have preceding _underscores in the file name, so Rails knows these to be "partials", but they are also located in the views
folder, and in the layout
folder. So what name does it go by?
The issue above leads me to not understand what someone is talking about, since I also might not be structuring the files accordingly. The scoping issue (which, to my knowledge, when you call render 'action'
or render 'file'
etc..., rails can find another controllers view and action) plays into using render
vs content_for
/yield
. Look at my SO question here, in Geoff's answer, in his comments when I asked, "so it is not possible to use yield from other views?", his answer was that "That is certainly not the intent".
So back to what the original question, I dont feel that these are explained as they relate to each other. I am interested in making a robust application, and I understand how it can be accomplished with other smaller frameworks, but I need to understand at a higher level how rails processes the Views (MVC, the V) using the layouts, partials, templates and views, and how the files should be structured accordingly.
I would also like either a diagram or explanation of the terms that describe them, as well as their relationship to other (usage, parent/child of another) and conventional placing. This would look something like:
A view is what is presented to the user. It is comprised of several parts.
The following are required [ templates, layouts ].
These are not required, but very likely once you have a robust and
flexible program [ partials, yields/content_for ].
A layout is a framework ....
A Partial is content, but only "partial" of a page....
A rendered file is ... and is located in each model's view