All, I''m writing a generic application helper that will take an object and then attempt to generate the name of the appropriate RESTful route helper for POST and PUT. Here it is so far: def get_form_url(object) tableized_name = object.class.name.tableize update_helper = "#{tableized_name}_url" #This should return the correct URL based on whether the object is new or not. #But what should be in ???? ????.send(''update_helper'', object) end So, as an example, if I have an object of type "ServiceOption", then the update_helper will be "service_options_url", which assuming that there is a "map.resources :service_options" line in my routes.rb, will be a valid URL helper for this object. The trick is I need to dynamically call the URL helper and I don''t know which object to send the message to. What should ???? be above. Thanks, Wes -- 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 -~----------~----~----~----~------~----~------~--~---
Correction:> def get_form_url(object) > tableized_name = object.class.name.tableize > update_helper = "#{tableized_name}_url" > > #This should return the correct URL based on whether the object is new > or not. > #But what should be in ???? > ????.send(update_helper, object) > end-- 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 -~----------~----~----~----~------~----~------~--~---
ANSWER: This is what the method should look like: def get_update_url(object) camel_case_object_name = object.class.name.underscore eval("#{camel_case_object_name}_url(object)") end My problem was the camel case version of the class name was plural (tableize vs. underscore inflection). This seems to work fine. Thanks, Wes -- 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 -~----------~----~----~----~------~----~------~--~---