Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between a view and a layout in RoR?

What is the difference? I ask because I'm just starting RoR dev, and I need to modify an application to add a new div to a page. I want to be able to render this div independently, and currently the rhtml code is part of the view of the page that will be rendered. I assume I would need to move this into a partial layout from what I have gathered so far.

like image 981
alexD Avatar asked Dec 16 '22 04:12

alexD


1 Answers

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

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

The layout is a template that contains shared DOM components, the View is what fills this template.

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

like image 102
Bassam Mehanni Avatar answered Mar 16 '23 21:03

Bassam Mehanni