This project is archived and is in readonly mode.

#881 ✓wontfix
Ryan Bates

Refactoring ActionView::Partials

Reported by Ryan Bates | August 22nd, 2008 @ 01:04 AM

I saw some potential refactorings for ActionView::Partials to remove some duplication and clean things up. Attached is a patch.

Here's an overview of what I did.

  • render_partial and render_partial_collection now take option hashes to simplify their argument list.
  • render_partial is the gateway to all partial rendering, this simplifies the Base render methods
  • split up rendering into multiple methods to handle the various object types: array, form, string, and other objects. These methods call each other to stay dry.
  • the counter is now internally stored in local_assigns as "collection_counter" to simplify rendering of collections. I'm not entirely happy with moving this logic into Renderable#compile, but I couldn't think of a cleaner solution.

Let me know what you think.

Comments and changes to this ticket

  • josh

    josh August 22nd, 2008 @ 01:52 AM

    • State changed from “new” to “wontfix”
    • Assigned user set to “josh”
    • Milestone cleared.

    I don't like

    • I'm against adding more private methods to the view context. It would be better to push that logic into RenderablePartial and break it up if possible.
    • The Renderable#compile! method should have no logic concerning partials. I'd override compile! in RenderablePartial to add extra behavior.
    • Why do you need to change the assertion in test_render_partial_collection_without_as?

    I do like

    • Moving useful logic (from ActionController) into ActionView.
    • The idea of cleaning up Partial logic in general ;)
  • josh

    josh August 22nd, 2008 @ 03:05 AM

    Took some of your ideas and cleaned up a few others things. Gave you the cred though.


  • Ryan Bates

    Ryan Bates August 22nd, 2008 @ 05:32 AM

    Cool, thanks for doing that.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>

People watching this ticket


Referenced by