I new to Ruby on Rails, and I am coming from Drupal/PHP background.
I am trying to do something simple. A "Static" controller for some pages like about us, disclaimer etc. and a "Video" controller for videos.
The whole application has same look. I am trying to figure out how I can avoid duplicating views.
In drupal the theming goes like this: html.tpl.php (renders page.tpl.php) - page.tpl.php (renders multiple block.tpl.php) - block.tpl.php (renders more nested tpls or some html generated by theme functions).
I find this to be great.
In rails, what I read is there is application.html.erb (Which I think is similar to html.tpl.php of Drupal, as it normally contains stylesheets, js, etc. available throughout the application) called "Layout". Then there are "Views", which "yield" content in this layout. We specify the view in controller, or it gets one automatically. I think of a view as "page.tpl.php" of Drupal.
Most of my site uses same structure i.e. header, top menu, content, right sidebar, footer. But content of each area changes depending on the path. So I am thinking of doing it like this:
- Both 'Static' & 'Video' will call the same view, with different variable values i.e. values for content area and sidebar.
- This View will the use 'render' to render another view, with a subset of variables passed from controller i.e. it will render content & sidebar views.
- If needed, those views will render more views, and so on.
Another one I read about is partials. I can't seem to differentiate between rendering a view inside another view, and rendering a partial.
Which method is better? Or is there a better "Rails Way"?