General path question


#1

Hello all,

I am currently building my first RoR application. On the server side,
I have a web service that will fetch some data from a third party
provider and display it to the my user. I have a couple of question on
best practices.

I am using WSDL scanning which gives a lot of overhead a take couple
of seconds to accomplish. I have my class that will deal with all the
wweb service call in the model diectory. I called it
postcode_anywhere_service.rb. My first question is: should it be a
singleton (will that be scalable do you beleive?) I know this is
somewhat a general question and would be happy to hear some advices.

So I have this web_Service class defined in my model directory. In my
controller (postcode_controller), I want to initialize
postcode_anywhere_service.rb only once (per user? I am not sure which
is best - should I initialize it once for all users or once per usere.
Each user will have a couple of request…). I put it in the
initialize definition of the postcode_controller. I beleive it should
not be in there but can not find a best practise for initialization.

Basically, if it can be scalable, I want to define each def in the
postcode_anywhere_service to be self called. So I could use
PostcodeAnywhreService.getAddress(postcode) for exemple without
instantiating it each time. But for that I need to instantiate the
class a first time before calling the above. What is the best solution
to do so? Will it be scallabe?

Thanks a lot for any comments, tutorials ect…
Carl-Gustaf H.