title: create a wrapper controller for all calls to web services in rails
body: <p>I am working to creating a wrapper for my existing application controllers.</p>
  
  <p>For example, i have two controllers accepting similar set of parameters and similar methods. </p>
  
  <p>Code is as below</p>
  
  <pre><code>class EmployeeController &lt; ApplicationController
  
    def list
    end
  
  end
  
  
  class DepartmentController &lt; ApplicationController
  
    def list
    end
  
  end
  </code></pre>
  
  <p>end point would be <strong><a href="http://localhost:3000/employee/list" rel="noreferrer">http://localhost:3000/employee/list</a></strong>
  &amp;
  <strong><a href="http://localhost:3000/department/list" rel="noreferrer">http://localhost:3000/department/list</a></strong> </p>
  
  <p><strong>What is the best way to create wrapper controller and invoke either of the controllers action.</strong></p>
  
  <p>is this way correct, where we check certain parameters and create objects accordingly or are there better ways to do it </p>
  
  <pre><code>class WrapperController &lt; ApplicationController
  
  
    def list
      if params["which"].eql?("employee")
        data = EmployeeController.new(params).create
      else
        data = DepartmentController.new(params).label
      end
  
    end
  end
  </code></pre>
  
  <p>end point would be <a href="http://localhost:3000/wrapper/list" rel="noreferrer">http://localhost:3000/wrapper/list</a></p>
  
  <p>Any help would be appreciated. Thanks in advance.</p>