Reputation: 2364
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.
Upvotes: 4
Views: 3722
Reputation: 14944
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
Upvotes: 8
Reputation: 3818
The view is context based, i.e. related to the particular controller#action you are hitting based on the RESTful URL being requested. The controller#action serves your request and delegates the appropriate view to be yielded back to your 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 partials.
Upvotes: 4