How to use Controller instance methods inside (Web Service) API Services

Hi All,

I am using AWS to implement web service APIs in rails and i am using
Layered dispatching mode for implementation.

Here i am not getting how can i use controller’s instance methods
(both user defined and built in) inside my API service.

As an example below take below things in consideration.

this is API signature.

class ProductApi < ActionWebService::API::Base

 api_method :find_all_products,
 :returns => [[:int]]

api_method :find_product_by_id,
:expects => [:int],
 :returns => [Product]


this is layered_backend controller.

class LayeredBackendController < ApplicationController

  dispatching_web_service_mode :layered
  web_service_scaffold :invoke
  web_service(:order) { }

  def test_method
     # some code


this is order_service.rb file.

class OrderService< ActionWebService::Base
web_service_api ProductApi

 def find_all_products
     Product.find(:all).map{ |product| }

 def find_product_by_id(id)


Now if i want to use my controller instance method named test_method
inside OrderServie then how can i use it ?

and also how to use controller built in instance methods (like
session, log_error etc )inside OrderService ?

Thanks in Advance.


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs