1 to 11 of 11
3) How can I include two listings (each from a separate table) on a single page?
using partials.
the default add.tpl uses
<?php echo $controller->renderPartial('form') ?>
can be rewritten using sintags
<%= render_partial 'form' %>
<%= render_partial 'path/form' %>
!path is relative to the views path !
you can pass a variable like
<%= render_partial 'form', :var => Books %>
or something like this. etc...
there are different opinions of how to get the data of two models and especially where to locate the 'logic' - some think getting data is very 'busy business' - though.
you can do it in the view, in a before-filter in the controller. dadadum etc.
you said you've managed issues #1 & #2.
then actually we're having two solutions. your solution and using partials.
I would like to know your little secret. ;-)
And if anyone else was scratching their head on how to do this in a file inside the layouts directory, remember that the path is relative to the Originating Model's view directory.
Here's what I did to get a header:
1. Put a file "header.tpl" in the layouts directory. (It's application wide, so I figured this was a ok place to stick it. Suggestions welcome)
2. Inside the part.tpl file (Also in the layouts directory), I put this just under the BODY tag:
<%= render_partial '../layouts/header' %>
I hope that saves someone else a few minutes of loose hair. :-)
curious.
<%= render_partial 'layouts/footer' %>
should work
Odd, I thought I'd tested yet. Yup, it works fine, and looks better. Why would both work though? Doesn't ../ refer to one directory up the tree?
1 to 11 of 11