Topic: Where to store code?


Where should I put code that makes request to web-service?

Obviously I can't put it in controller. It seems to me to store is in Model is the strange idea too, because code doesn’t work with database.

Re: Where to store code?

You could put them in a controller?  Nothing wrong with that,  if they need to be available to all your controller actions,  put them in ApplicationController and make sure all of your controllers inherit from Application controller.  If all the actions that call the web services are in a single controller,  just put them in that controller.

Or you could put them in the lib directory of your rails app.   If they need any kind of initialization at startup,  you would put that in a ruby file of your choosing in config/initializers, i.e.


Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.