# Partials access to local objects

**URL:** <https://www.ruby-forum.com/t/partials-access-to-local-objects/200496>\
**Category:** Radiant CMS\
**Created:** [December 13, 2010, 8:05pm UTC](https://www.ruby-forum.com/t/partials-access-to-local-objects/200496 "2010-12-13T20:05:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [December 13, 2010, 8:05pm UTC](https://www.ruby-forum.com/t/partials-access-to-local-objects/200496/1 "2010-12-13T20:05:46Z")

</div>

I’m writing an extension to add a new feature to the “taggable”  
extension and I need to do something very simple: add a new column to  
the taggable index page. This is pretty simple:

admin.tag.index.add :thead, “add\_required\_header”, :after =\>  
“modify\_header”  
admin.tag.index.add :tbody, “add\_required\_cell”, :after =\>  
“modify\_cell”

However, in my partial, I need to reference the tag object from  
index.html.haml:

- for tag in @tags  
%tr.node.level-1  
- render\_region :tbody do |tbody|  
.  
.  
.  
/ Partial code should be inserted here  
/ - tbody.required\_cell do  
/ - if tag.required  
/ Required

However, the “tag” object is not available within the partial. Is  
there any way I can get access to that when I’m adding code via  
partials?

---

<div class="post-metadata">

**Author:** ![bradherman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbce88/32.png) [@bradherman](https://www.ruby-forum.com/u/bradherman)\
**Post date:** [December 13, 2010, 9:23pm UTC](https://www.ruby-forum.com/t/partials-access-to-local-objects/200496/2 "2010-12-13T21:23:08Z")

</div>

On 13 Dec 2010, at 19:05, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> index.html.haml:  
> / Required
> 
> However, the “tag” object is not available within the partial. Is  
> there any way I can get access to that when I’m adding code via  
> partials?

No. It’s a weakness of the otherwise very cunning shards mechanism that  
there is no way for it to get at local variables.

Taggable could help, perhaps by including an empty partial  
(\_other\_columns.html.haml?) with some locals or by setting a  
@current\_tag variable within the index-page loop. Neither approach is  
very pleasing, but it will take a while to arrive at a better solution  
that is also simple enough to live with.

I need to clear up that index page anyway (as you can see from the  
‘node.level-1’). Would anyone like to suggest a best practice here?

will
