Hi, I have an ActiveRecord which has several dynamically created has_one associations using a plugin has_one :foo has_one :bar and when I do @foo = @my_active_record_object.foo everything works well. I''d like to be able to call them dynamically using a string using @foo = @my_active_record_object.send(''foo'') but this doesn''t appear to work... any thoughts? Thanks, Rich -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 11/10/06, Rich H <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I have an ActiveRecord which has several dynamically created has_one > associations using a plugin > > has_one :foo > has_one :bar > > and when I do > > @foo = @my_active_record_object.foo > > everything works well. > > I''d like to be able to call them dynamically using a string using > > @foo = @my_active_record_object.send(''foo'') > > but this doesn''t appear to work... any thoughts?That should work. Those two forms are the same for the object (unless some of your plugins changed "send" instance method of AR::Base =)) Any method_missing tricks won''t distinguish those two forms of method invocation. Maybe you''re doing something wrong elsewhere ? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---