I'm pretty much sold on this. The one thing is of course that it
doesn't have to boil down to a single name. The form builder can
easily be made available under more than one name if there's a demand
for that (so you could just always make it available as f, but I
think that would be a bit ugly.
Or is this super evil ;-)
class FormBuilder
def partial(name, options={}, &block)
builder_name = nil
block_locals = eval('local_variables', block.binding)
block_locals.each do |local|
value = eval(local, block.binding)
builder_name = local and break if value == self
end
@template.render options.merge(:partial => name, :object =>
self, :locals => {builder_name => self})
end
end
form_for(...) do |f|
f.partial('form'){}
end
this will work find what name (or rather one of the names) the form
builder had when the partial method was called
Fred
On 25 Sep 2007, at 22:30, Mislav Marohnić wrote:
> On 9/25/07, Pratik <[EMAIL PROTECTED]> wrote:
>
> Why not use name of the partial to refer to form object ?
>
> Consistency!
> +1
>
> - Mislav
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---