What is the difference between presentation and layout in RoR?

What is the difference? I ask because I am just starting RoR dev and I need to change the application to add a new div to the page. I want to be able to make this div on my own, and currently the rhtml code is part of the presentation of the page to be displayed. I assume that I will need to move this to a partial layout from what I have put together so far.

+4
source share
2 answers

The view is based on context, that is, associated with a specific controller action # that you click, based on the requested RESTful URL. The controller action # serves your request and delegates the appropriate view to return to the base application template.

You will find <%= yield %> in your application.html.erb for this very reason.

As for your first question, Bessam is correct, and you need to look at partial ones.

+3
source

What you need is a partial view, not a partial layout.

http://api.rubyonrails.org/classes/ActionView/PartialRenderer.html

A layout is a template containing common DOM components, the view of which fills this template.

http://guides.rubyonrails.org/layouts_and_rendering.html

+8
source

Source: https://habr.com/ru/post/1395336/


All Articles