Kandada Boggu
2011-Mar-04 02:55 UTC
How to invoke a controller action from another controller in-memory?
I have a rails server that serves mobile clients(native) and a browser based client. Most of the trafic comes from the browser based client. The browser based client goes through an intermediary rails server to get the views. The central server exposed REST based services. [ Iphone +---------------+ Blackberry | | Android ]<-------------------------------------->| Central Rails| | Server | | | [ Browser ]<------->[intermediary server]<-------->| |+---------------+ System is in production for last 8 months. Recently, during one of the performance tuning exercises, we noticed that XML serialization/de- serialization costs are very high for ActiveResource communications. So we are trying to co-locate the intermediary server and the central rails server controllers in rails server instance. I can rewrite the Intermediary controllers to directly use the models. This approach requires rewriting lot of code and I will loose all the authorization checks enforced through the central controllers. I am trying to figure out how to invoke the central server controllers from the intermediary server controller without incurring the serialization/deserialization costs. Ideally, I would like the existing central controllers to return an in memory object rather than a XML string. Eg: Central controller: class ActiveRecord::Base def to_ar self end end class UserController def show respond_to do |format| format.xml { render :xml => @user } format.json { render :json => @user } format.ar { render :ar => @user } end end end Central controller: app.get ''/users/1.ar'' @user = app.response.body Any pointers/advises will be highly appreciated. **PS**: I am on Rails 2.3.9. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.