M
M
Maxim Grechushnikov2014-11-19 00:06:29
Ruby on Rails
Maxim Grechushnikov, 2014-11-19 00:06:29

Rails: How to add dynamic content to Layout?

Colleagues, please tell me the principle: how to add some dynamic content to application.html.erb in ruby? in the form of widgets / helpers or something else?
in particular, you need a website header that displays a list of cities from the database. How is this block made?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
Jeiwan, 2014-11-19
@maxyc_webber

The problem is not entirely clear. Dynamic content can already be written in application.html.erb itself, as in any template. Ruby code can be inserted into the template inside the <%= %> tags (with output to the page) or <% %> (without output).
Perhaps you need to render the header through a parsial:
This code will include the markup from the header.html.erb file next to application.html.erb in its call site.
Accordingly, you can load different parsials depending on the parameters.

R
romanwb, 2014-11-19
@romanwb

Or helpers or content_for api.rubyonrails.org/classes/ActionView/Helpers/Cap...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question