Question

I have been using the server url at many places over the application. If I would need to change it then I need to go all over the place I have used to change it.

Where should be the best place to declare the url so it can be used every where and not much change is required?

Was it helpful?

Solution

You can declare the server URL in the RhoConfig.xml file as a property. And later, retrive the property value during the API calls.

So to delare the property in RhoConfig.xml, you need to add it as such,

   start_path = '/app'
   options_path = '/app/Settings'
   server_URL = 'http://somedomain.com/API/'

Now in the Controller to get the value of the server_URL, you need to call the Rho::RhoConfig class and use it as like below,

   if Rho::RhoConfig.exists?('server_URL')
       $server_url = Rho::RhoConfig.server_URL
   end 

This makes the url to change on one place if required.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top