partials in rails

View: New views
5 Messages — Rating Filter:   Alert me  

partials in rails

by Adam Akhtar-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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?
--
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@...
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: partials in rails

by Bugzilla from leonardomateo@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Sat, Nov 7, 2009 at 9:03 AM, Aashish Kiran
<rails-mailing-list@...> 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:
http://guides.rubyonrails.org/layouts_and_rendering.html#using-partials


--
Leonardo Mateo.
There's no place like ~

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@...
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: partials in rails

by Todd A. Jacobs-20 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Sat, Nov 07, 2009 at 01:03:37PM +0100, Aashish Kiran 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"


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@...
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: partials in rails

by Adam Akhtar-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Todd A. Jacobs wrote:
> On Sat, Nov 07, 2009 at 01:03:37PM +0100, Aashish Kiran 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
marnen@...
--
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@...
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: partials in rails

by Adam Akhtar-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Aashish Kiran 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



--
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@...
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---