I am new to rails. can anyone explain in detail about partials in rails.
my rails version is 2.3.4.
How to use them?
On Sat, Nov 7, 2009 at 9:03 AM, Aashish K.
[email protected] wrote:
I am new to rails. can anyone explain in detail about partials in rails.
my rails version is 2.3.4.
How to use them?
Have you search something about this? I’m pretty sure this has been
explained zillions of times before, for example, here:
–
Leonardo M…
There’s no place like ~
On Sat, Nov 07, 2009 at 01:03:37PM +0100, Aashish K. wrote:
I am new to rails. can anyone explain in detail about partials in
rails. my rails version is 2.3.4. How to use them?
Partials are basically “includes.” The tricky part is generally getting
variables from the main view to propagate to the partial. This requires
using “:locals=>{}” properly, which doesn’t always seem to work the way
I expect.
–
“Oh, look: rocks!”
– Doctor Who, “Destiny of the Daleks”
Todd A. Jacobs wrote:
On Sat, Nov 07, 2009 at 01:03:37PM +0100, Aashish K. wrote:
I am new to rails. can anyone explain in detail about partials in
rails. my rails version is 2.3.4. How to use them?Partials are basically “includes.” The tricky part is generally getting
variables from the main view to propagate to the partial.
Not tricky at all.
This requires
using “:locals=>{}” properly, which doesn’t always seem to work the way
I expect.
It has always worked for me. Can you provide an actual example that
doesn’t work?
–
“Oh, look: rocks!”
– Doctor Who, “Destiny of the Daleks”
Best,
Marnen Laibow-Koser
http://www.marnen.org
[email protected]
Aashish K. wrote:
I am new to rails. can anyone explain in detail about partials in rails.
my rails version is 2.3.4.
How to use them?
You can think of partials as making function calls from your erb files
which generates templated html for you. The values for template
variables you can pass through local and object variables. If you want
same set of templated html to be generated from N places in your site,
you can create a partial and call this from all of these N places. Any
time you want to change the code you change in one place rather than N
places. It helps you to follow DRY principle.
Thanks
– Prasad
http://roorky.com
Digital Interactive Publication