Rails includes a page

How to include a page from a shared folder in one of my views? I want to include one header, as in PHP, so when I make changes, it affects all other pages. (This is for several species)

+3
source share
2 answers

For the most part, the only web pages in the shared folder will be purely static (404 user pages, FAQs, etc.). If you have static HTML that you want to display on a large number of pages, partial is what to look for.

Partial does not have to bind to the controller. You can create a subdirectory:

/views/static

and fill it with a whole piece of partial, so you will have:

/views/static/_my_first_partial.html.erb
/views/static/_my_second_partial.html.erb

, , :

render :partial => "static/my_first_partial"

, !

+3

, , :

+2

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


All Articles