On 13 Dec 2010, at 19:05, bradley.t.her...@gmail.com wrote: > 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?
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