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