Joe
Joe

Reputation: 379

How to use a rails layout when multiple sections of a page can change?

I am making a rails application and I have created a couple of views and can switch to them using the "link_to".

The problem I am having is that I need to change two sections (the header and content) in a page with 4 sections (also sidebar and footer).

I wish to use the same layout for all the views, just change the content in two sections.

I am using this tutorial https://www.railstutorial.org/book/filling_in_the_layout but do not know if the answer is there. I've been through two tutorials already, which were helpful, but neither of them has addressed the concerns I am trying to solve.

Any idea what I can search for to find the answer? Or if the tutorial I am using has the answer in it? Or if there is another tutorial somewhere that explains the process?

Upvotes: 1

Views: 46

Answers (1)

ilan berci
ilan berci

Reputation: 3881

You can yield the various sections in your layout to content_for blocks,

Check out http://guides.rubyonrails.org/action_view_overview.html (section 6.6.2)

Upvotes: 3

Related Questions