Greg Willits
2008-May-21 01:28 UTC
How get instance of form_for object from @object_name ?
I have a custom form builder. In it I have a method for retrieving validation error messages. Currently it gets used like this: <% form_for :my_obj..... <%= form.draw_invalid_msg(my_obj.errors[:userHosts]) %> I would like to reduce that to this: <%= form.draw_invalid_msg(:userHosts) %> My method code would that start with something like this: def draw_invalid_msg(field_name) invalid_messages = @object_name.errors[field_name] Well, that doesn''t work, of course, because @object_name is just a symbol, not the actual AR object data. So, yes, I could explicitly pass in the obj to start with, but that''s exactly what I am trying to eliminate. So, what introspective tricky can be used to yield access to the actual object within :my_obj via the @object_name ivar value? Make sense? -- gw --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I think this will get it: invalid_messages = instance_eval("@#{object_name}").errors[field_name] On May 20, 9:28 pm, Greg Willits <li...-0Bv1hcaDFPRk211Z5VL+QA@public.gmane.org> wrote:> I have a custom form builder. In it I have a method for retrieving > validation error messages. > > Currently it gets used like this: > > <% form_for :my_obj..... > <%= form.draw_invalid_msg(my_obj.errors[:userHosts]) %> > > I would like to reduce that to this: > > <%= form.draw_invalid_msg(:userHosts) %> > > My method code would that start with something like this: > > def draw_invalid_msg(field_name) > invalid_messages = @object_name.errors[field_name] > > Well, that doesn''t work, of course, because @object_name is just a > symbol, not the actual AR object data. So, yes, I could explicitly > pass in the obj to start with, but that''s exactly what I am trying to > eliminate. > > So, what introspective tricky can be used to yield access to the > actual object within :my_obj via the @object_name ivar value? > > Make sense? > > -- gw--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Greg Willits
2008-May-21 04:58 UTC
Re: How get instance of form_for object from @object_name ?
Nope. I think your idea would have needed @object_name not just object_name, but that didn''t work either. I tried a few versions with eval too, but no luck so far. -- gw On May 20, 2008, at 8:59 PM, AndyV wrote:> I think this will get it: > > invalid_messages = instance_eval("@#{object_name}").errors[field_name] > > On May 20, 9:28 pm, Greg Willits <li...-0Bv1hcaDFPRk211Z5VL+QA@public.gmane.org> wrote: >> I have a custom form builder. In it I have a method for retrieving >> validation error messages. >> >> Currently it gets used like this: >> >> <% form_for :my_obj..... >> <%= form.draw_invalid_msg(my_obj.errors[:userHosts]) %> >> >> I would like to reduce that to this: >> >> <%= form.draw_invalid_msg(:userHosts) %> >> >> My method code would that start with something like this: >> >> def draw_invalid_msg(field_name) >> invalid_messages = @object_name.errors[field_name] >> >> Well, that doesn''t work, of course, because @object_name is just a >> symbol, not the actual AR object data. So, yes, I could explicitly >> pass in the obj to start with, but that''s exactly what I am trying to >> eliminate. >> >> So, what introspective tricky can be used to yield access to the >> actual object within :my_obj via the @object_name ivar value? >> >> Make sense? >>--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-May-21 06:24 UTC
Re: How get instance of form_for object from @object_name ?
On 21 May 2008, at 05:58, Greg Willits wrote:> > Nope. I think your idea would have needed @object_name not just > object_name, but that didn''t work either. > > I tried a few versions with eval too, but no luck so far. >form.object :-) Fred> -- gw > > > On May 20, 2008, at 8:59 PM, AndyV wrote: > >> I think this will get it: >> >> invalid_messages = >> instance_eval("@#{object_name}").errors[field_name] >> >> On May 20, 9:28 pm, Greg Willits <li...-0Bv1hcaDFPRk211Z5VL+QA@public.gmane.org> wrote: >>> I have a custom form builder. In it I have a method for retrieving >>> validation error messages. >>> >>> Currently it gets used like this: >>> >>> <% form_for :my_obj..... >>> <%= form.draw_invalid_msg(my_obj.errors[:userHosts]) %> >>> >>> I would like to reduce that to this: >>> >>> <%= form.draw_invalid_msg(:userHosts) %> >>> >>> My method code would that start with something like this: >>> >>> def draw_invalid_msg(field_name) >>> invalid_messages = @object_name.errors[field_name] >>> >>> Well, that doesn''t work, of course, because @object_name is just a >>> symbol, not the actual AR object data. So, yes, I could explicitly >>> pass in the obj to start with, but that''s exactly what I am trying >>> to >>> eliminate. >>> >>> So, what introspective tricky can be used to yield access to the >>> actual object within :my_obj via the @object_name ivar value? >>> >>> Make sense? >>> > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Greg Willits
2008-May-21 06:52 UTC
Re: How get instance of form_for object from @object_name ?
On May 20, 2008, at 11:24 PM, Frederick Cheung wrote:> form.object :-)ooOOOooo. Tricky! :-P -- gw (egads) On May 20, 9:28 pm, Greg Willits <li...-0Bv1hcaDFPRk211Z5VL+QA@public.gmane.org> wrote:> My method code would start with something like this: > def draw_invalid_msg(field_name) > invalid_messages = @object_name.errors[field_name] > > Well, that doesn''t work, of course > So, what introspective tricky can be used to yield access to the > actual object within :my_obj via the @object_name ivar value?--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Greg Willits
2008-May-21 08:07 UTC
Re: How get instance of form_for object from @object_name ?
Oops. Not so tricky. form doesn''t propogate into the custom builder methods -- which makes sense. So, I would guesd that form.object works inside the form, but it doesn''t inside a custom builder method. def draw_invalid_msg(field_name) invalid_messages = form.object.errors[field_name] That''s what I tried, which I should have recognized wasn''t going to work. -- gw> On May 20, 2008, at 11:24 PM, Frederick Cheung wrote: > >> form.object :-) > > ooOOOooo. Tricky! :-P > > On May 20, 9:28 pm, Greg Willits <li...-0Bv1hcaDFPRk211Z5VL+QA@public.gmane.org> wrote: >> My method code would start with something like this: >> def draw_invalid_msg(field_name) >> invalid_messages = @object_name.errors[field_name] >> >> Well, that doesn''t work, of course >> So, what introspective tricky can be used to yield access to the >> actual object within :my_obj via the @object_name ivar value?--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-May-21 08:12 UTC
Re: How get instance of form_for object from @object_name ?
On 21 May 2008, at 09:07, Greg Willits wrote:> > Oops. Not so tricky. form doesn''t propogate into the custom builder > methods -- which makes sense. So, I would guesd that form.object > works inside the form, but it doesn''t inside a custom builder method. > > def draw_invalid_msg(field_name) > invalid_messages = form.object.errors[field_name] > > That''s what I tried, which I should have recognized wasn''t going to > work. >is this in a form builder ? in which case self is the form build, so just object.errors should work Fred> -- gw > >> On May 20, 2008, at 11:24 PM, Frederick Cheung wrote: >> >>> form.object :-) >> >> ooOOOooo. Tricky! :-P >> >> On May 20, 9:28 pm, Greg Willits <li...-0Bv1hcaDFPRk211Z5VL+QA@public.gmane.org> wrote: >>> My method code would start with something like this: >>> def draw_invalid_msg(field_name) >>> invalid_messages = @object_name.errors[field_name] >>> >>> Well, that doesn''t work, of course >>> So, what introspective tricky can be used to yield access to the >>> actual object within :my_obj via the @object_name ivar value? > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Greg Willits
2008-May-21 08:26 UTC
Re: How get instance of form_for object from @object_name ?
On May 21, 2008, at 1:12 AM, Frederick Cheung wrote:>> def draw_invalid_msg(field_name) >> invalid_messages = form.object.errors[field_name] >> That''s what I tried, which I should have recognized wasn''t going to >> work. > > is this in a form builder ? in which case self is the form build, so > just object.errors should workYes, it is. Nope, it didn''t. Currently, my baseline code gets used like this: <% form_for :my_obj..... <%= form.draw_invalid_msg(my_obj.errors[:userHosts]) %> I would like to reduce that to this: <%= form.draw_invalid_msg(:userHosts) %> My custom form builder method would start with something like this: def draw_invalid_msg(field_name) invalid_messages = @object_name.errors[field_name] ...but I need a replacement for @object_name. form.object, or just object doesn''t work. This would be greatly simplified if the form builder had access to the originating controller''s instance variables, but that appears to not be the case (though I ran into false data on ivar scope before ;-) Anyway, it would seem that any variable usable within my form builder method must be an instance var like @object_name, and not just a local var like object ? -- gw --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-May-21 08:30 UTC
Re: How get instance of form_for object from @object_name ?
On 21 May 2008, at 09:26, Greg Willits wrote:> > > Yes, it is. Nope, it didn''t. > > Currently, my baseline code gets used like this: > > <% form_for :my_obj..... > <%= form.draw_invalid_msg(my_obj.errors[:userHosts]) %> > > I would like to reduce that to this: > > <%= form.draw_invalid_msg(:userHosts) %> > > My custom form builder method would start with something like this: > > def draw_invalid_msg(field_name) > invalid_messages = @object_name.errors[field_name] > > ...but I need a replacement for @object_name. form.object, or just > object doesn''t work. > > This would be greatly simplified if the form builder had access to > the originating controller''s instance variables, but that appears to > not be the case (though I ran into false data on ivar scope before ;-) >it''s a completely distinct object so would be a little crazy.> Anyway, it would seem that any variable usable within my form builder > method must be an instance var like @object_name, and not just a > local var like object ?it''s @object, but there''s an accessor, so object should work. There are plenty of built in helpers using @object so object/@object should work, unless you''re doing something really funny, Fred>--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Greg Willits
2008-May-21 08:49 UTC
Re: How get instance of form_for object from @object_name ?
On May 21, 2008, at 1:30 AM, Frederick Cheung wrote:> On 21 May 2008, at 09:26, Greg Willits wrote: >> >> Currently, my baseline code gets used like this: >> >> <% form_for :my_obj..... >> <%= form.draw_invalid_msg(my_obj.errors[:userHosts]) %> >> >> I would like to reduce that to this: >> >> <%= form.draw_invalid_msg(:userHosts) %> >> >> My custom form builder method would start with something like this: >> >> def draw_invalid_msg(field_name) >> invalid_messages = @object_name.errors[field_name] >> >> ...but I need a replacement for @object_name. form.object, or just >> object doesn''t work.>> Anyway, it would seem that any variable usable within my form builder >> method must be an instance var like @object_name, and not just a >> local var like object ? > > it''s @object, but there''s an accessor, so object should work. There > are plenty of built in helpers using @object so object/@object should > work, unless you''re doing something really funny,Just to be sure -- are you talking Rails 2.0? I am using 1.2.6. As far as I can tell, I''m not doing anything weird. Generated a form builder, have a number of HTML drawing methods that I use just fine. Nothing tricky, just some simple string rendering. Just to see if @object exists, I used debug(@object) right inside the form_for boundaries (not one of my builder methods), and I get nothing. if I debug (object) then I get local var not defined error. If I debug (my_obj) then I get a full object dump. So it seems to me dey ain''t no @object. So either it''s Rails 2 or I broke it. -- gw --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-May-21 09:26 UTC
Re: How get instance of form_for object from @object_name ?
On 21 May 2008, at 09:49, Greg Willits wrote:> > On May 21, 2008, at 1:30 AM, Frederick Cheung wrote: >> On 21 May 2008, at 09:26, Greg Willits wrote: >>> >>> Currently, my baseline code gets used like this: >>> >>> <% form_for :my_obj..... >>> <%= form.draw_invalid_msg(my_obj.errors[:userHosts]) %> >>> >>> I would like to reduce that to this: >>> >>> <%= form.draw_invalid_msg(:userHosts) %> >>> >>> My custom form builder method would start with something like this: >>> >>> def draw_invalid_msg(field_name) >>> invalid_messages = @object_name.errors[field_name] >>> >>> ...but I need a replacement for @object_name. form.object, or just >>> object doesn''t work. > >>> Anyway, it would seem that any variable usable within my form >>> builder >>> method must be an instance var like @object_name, and not just a >>> local var like object ? >> >> it''s @object, but there''s an accessor, so object should work. There >> are plenty of built in helpers using @object so object/@object should >> work, unless you''re doing something really funny, > > Just to be sure -- are you talking Rails 2.0? I am using 1.2.6. >Ah yes, I almost certainly am. No clue what''s going on in 1.2.6, although a cursory look at the source suggests it''s the same> As far as I can tell, I''m not doing anything weird. Generated a form > builder, have a number of HTML drawing methods that I use just fine. > Nothing tricky, just some simple string rendering. > > Just to see if @object exists, I used debug(@object) right inside the > form_for boundaries (not one of my builder methods), and I get > nothing. if I debug (object) then I get local var not defined error.if you mean <% form_for ... do |f| %> <%= object %> <% end %> then that won''t work (since object is evaluated in the context of the view, not in the context of the form builder (f.object should work there though).> If I debug (my_obj) then I get a full object dump. So it seems to me > dey ain''t no @object. So either it''s Rails 2 or I broke it. >Fred> > -- gw > > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Greg Willits
2008-May-21 10:25 UTC
Re: How get instance of form_for object from @object_name ?
>> Just to be sure -- are you talking Rails 2.0? I am using 1.2.6. >> > Ah yes, I almost certainly am. No clue what''s going on in 1.2.6, > although a cursory look at the source suggests it''s the same > >> As far as I can tell, I''m not doing anything weird. Generated a form >> builder, have a number of HTML drawing methods that I use just fine. >> Nothing tricky, just some simple string rendering. >> >> Just to see if @object exists, I used debug(@object) right inside the >> form_for boundaries (not one of my builder methods), and I get >> nothing. if I debug (object) then I get local var not defined error. > if you mean > > <% form_for ... do |f| %> > <%= object %> > <% end %> > then that won''t work (since object is evaluated in the context of the > view, not in the context of the form builder (f.object should work > there though).<% form_for :edp_target, :url => {:action => :record_editor}, :builder => EdpBuilder do |form| %> <%= debug() %> where () = (@object), (form.object), or (object) -- none yield any data. So, @object appears to be 2.0-specific. What I do have is @object_name, but I can''t figure out how to leverage that into a reference to the actual data held in @edp_target to which :edp_target is the name of. It''s not critical. I was just hoping to simplify something. -- gw --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-May-21 10:36 UTC
Re: How get instance of form_for object from @object_name ?
On 21 May 2008, at 11:25, Greg Willits wrote:> >>> Just to be sure -- are you talking Rails 2.0? I am using 1.2.6. >>> >> Ah yes, I almost certainly am. No clue what''s going on in 1.2.6, >> although a cursory look at the source suggests it''s the same >> >>> As far as I can tell, I''m not doing anything weird. Generated a form >>> builder, have a number of HTML drawing methods that I use just fine. >>> Nothing tricky, just some simple string rendering. >>> >>> Just to see if @object exists, I used debug(@object) right inside >>> the >>> form_for boundaries (not one of my builder methods), and I get >>> nothing. if I debug (object) then I get local var not defined error. >> if you mean >> >> <% form_for ... do |f| %> >> <%= object %> >> <% end %> >> then that won''t work (since object is evaluated in the context of the >> view, not in the context of the form builder (f.object should work >> there though). > > <% form_for :edp_target, > :url => {:action => :record_editor}, > :builder => EdpBuilder do |form| %> > > <%= debug() %> > > where () = (@object), (form.object), or (object) -- none yield any > data. >Reading the source, it appears that form_for :edp_target, @edp_target will populate object properly with @edp_target (and with 2.0, just form_for @edp_target would work) Fred> So, @object appears to be 2.0-specific. > > What I do have is @object_name, but I can''t figure out how to > leverage that into a reference to the actual data held in @edp_target > to which :edp_target is the name of. > > It''s not critical. I was just hoping to simplify something. > > -- gw > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Greg Willits
2008-May-21 10:48 UTC
Re: How get instance of form_for object from @object_name ?
On May 21, 2008, at 3:36 AM, Frederick Cheung wrote:> On 21 May 2008, at 11:25, Greg Willits wrote: > >> Just to be sure -- are you talking Rails 2.0? I am using 1.2.6. >> >> Just to see if @object exists, I used debug(@object) right inside >> the >> form_for boundaries (not one of my builder methods), and I get >> nothing. if I debug (object) then I get local var not defined error.>> <% form_for :edp_target, >> :url => {:action => :record_editor}, >> :builder => EdpBuilder do |form| %> >> >> <%= debug() %> >> >> where () = (@object), (form.object), or (object) -- none yield any >> data. > > Reading the source, it appears that form_for :edp_target, @edp_target > will populate object properly with @edp_target (and with 2.0, just > form_for @edp_target would work)Ah. OK, after more tinkering using this version: <% form_for :edp_target, @edp_target, form.object is populated within the form_for boundaries, but @object is not. However, in my EdpBuilder methods, @object is available-- which is all I need. From there, I can do what I need. Thanks for sticking with this Fred -- as always your vantage point has helped. I''m going to owe you a nice dinner someday. -- greg --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> Nope. I think your idea would have needed @object_name not just > object_name, but that didn''t work either. > > I tried a few versions with eval too, but no luck so far. > > -- gw >It should have been the symbol of the name of the object. The instance_eval statment would get inspected into @some-named-object via string interpolation and the instance_eval would have evaluated that against the instance. FWIW, I''ve used that trick to do something very similar to what you''re after. I built a little lib of methods that allow me to use ruby syntax to generate extjs compatible javascript. In my scenario I was emulating form_for with ext_form_for and needed to account for the cases where you either supplied a symbol (that stood for the name of the object) or a symbol and the object (as an instance variable). Of course I ripped all that off by studying the Rails form_for. :) --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---