I have a ruby web application and I want to structure the UI layer to have a few templates made up of a number of various divs - something like header, footer, and other things that will repeat throughout pages.
What I am wondering is: 1) Within the Ruby on Rails directory structure, where should these divs live? Somewhere under app/views/layouts ?
2) What is the syntax 开发者_如何学Cto import a div in order to still preserve the values of the variables set in the controllers?
Thanks!
You are referring to "Partials"
http://guides.rubyonrails.org/layouts_and_rendering.html (section 3.4)
Specifically, look at the locals
option.
Layouts are usually in 'views' but you can change where they exist. views/layouts
will work fine.
精彩评论